HowToQtQmlOnTheIOS

From Qt Wiki
Jump to navigation Jump to search
This article is nominated for deletion. Reason: Can't fix, encoding broken.
Please raise your support/opposition to this nomination in the article's discussion page.

Korean

Qt/QML 를 iOS 상에서 구동시키는 방법

무엇보다도 먼저 이 글은 Eike Ziller의 Qt Labs Developer Blogs 의 글을 기반으로 쓰여 졌으며 그의 Original글은 ( http://labs.qt.nokia.com/2011/08/09/update-on-uikit-lighthouse-platform ) 을 통해 확인 할 수 있음을 알린다. Deeply thanks to Eike Ziller

이 글의 목적은 원본 글에서 나타나는 바와 같이 pre-Qt 4.8 이나 pre-Qt 5 에서 제공된 UIKit plugin의 기능을 사용하여 QML/Qt가 iOS device에 동작 혹은 Qt application 사용 가능함을 보여주는 데 있을 뿐이지, 현재 Qt가 공식적으로 iOS를 사용하는 device들을 지원함을 의미하지 않습니다. 특히 아래글은 iOS Device에서 QML-based GUI 를 사용하는 방법에 대해서 기술하고 있습니다. 그리고 현재 cocoa (Mac support) plugin이 아닌 UIKit (iOS support) plugin은 모든 Qt class들의 성능을 보장하지 않습니다.

20011년 9월말 현재 Qt/QML 을 iOS 상에서 구동시킬 수 있는 방법은 다음과 같다고 알려져 있습니다. 1) Qt-iPhone Project

http://www.qt-iphone.com

2-1) Qt 4.8 lighthouse (QPA open source)

https://qt.gitorious.org/qt

2-2) Qt 4.8 lighthouse (QPA close source) 3) Qt 5.0

https://qt.gitorious.org/qt/qt5

각 Plugin의 장단점과 제약 사항에 대해서는 이글의 범위에 벗어 나므로, 기회가 있을 때 다른 블로그 글을 통해 소개 드리도록 하겠습니다. 제가 이 글을 통해 여러분에게 소개하려는 case는 2-1 Qt 4.8 lighthouse open source를 통한 방법입니다. 그리고 위에 상태에 대한 원본글은 다음과 같습니다. 참조 바랍니다.

There is general work being done in Qt 4.8 to ensure that it is iOS-compatible when it is released. There are two plugins being developed for Qt on iOS, but only one of them is currently open source. The open source plugin (aka. proof-of-concept UIKit plugin) was developed at Nokia, is (currently) part of Qt 4.8 and was discussed in a QtLabs blog post (in February?). That plugin however is only able to run simple QML apps and does not support more advanced features like auto-rotation, multi-touch, OpenGL, retina displays & widgets. The other plugin (aka. Qt iOS plugin) is currently closed source, supports full Qt GUI with widgets, multi-touch, multi-threaded OpenGL, shader effects, Qt3D, Qt Scenegraph & parts of Qt Mobility. This is the plugin that was used to make some YouTube demo videos (in Oct/Nov last year) & was shown on the iPad at QtCS. The Qt iOS plugin is currently being used to produce a trial-run application for submission to the Apple App Store, and more information etc. about that plugin will be made available once it has passed the App Store trial-run and can be considered for commercial application development. PS. The qt-iphone project is unrelated to these efforts and will most likely never be able to be used to run QML on iOS (if it is in fact still being developed). The purpose of that project is to be able to use Qt to write native UIKit applications. The purpose of Lighthouse (and the iOS plugins for it) is to be able to build and run standard Qt applications on iOS.

준비 해야 할 사항

1) Mac OS X machine ( Lion 혹은 Snow Leopard )

2) XCode 설치 http://developer.apple.com/technologies/tools/

만일 OS 텐 라이언을 사용하고 계시다면 XCode 4, OS 텐 스노우 레오퍼드를 사용하고 계시다면 XCode 3를 설치하셔야 합니다.

이후 설명은 Mac OS X Lion + XCode 4를 사용하고 계시는 것을 기준으로 설명드립니다.

3) Qt SDK 설치 (optional) http://qt.nokia.com/downloads/

Repository에 존재하는 example이 아닌 Qt module을 만들거나 Template들을 가져오고자 할때 쓰입니다.

4) MacPorts 설치 (optional) http://www.macports.org/

Gitorious를 사용하기 위해 필요합니다. dmg 파일을 다운로드 받아 사용하시면 편합니다.

Qt 4.8 가져오기

Gitorious Tool은 아무 것이나 사용하셔도 됩니다.

Qt repository를 Cloning 해 줍니다.
'''# git clone git://gitorious.org/qt/qt.git qt'''
(Qt의 전체 소스를 가져오기 때문에 시간이 조금 걸립니다)
'''# cd qt'''
원격 레포지토리를 로컬 레포지토리로 추가
 # git remote add qt git://gitorious.org/qt/qt.git
 # git fetch qt
 # git checkout -b my-local-Qt4.8 qt/4.8

위와 같이 하면 4.8의 소스 코드가 다운로드 됩니다.

자신의 branch를 확인해 보고 싶으시다면

 # git branch -a
와 같이 해보면 됩니다. 정상적으로 되었다면 my-local-Qt4.8과 같이 본인이 만든 branch 이름 앞에 (*) 표시가 되어 있습니다.

Qt의 shadow build

일반적인 경우는 normal build를 해도 관계없지만 iOS용으로 Qt를 compile 하실 경우에는 shadow build를 추천드립니다. 왜냐하면 xcode에서 device용과 simulator용을 구분하기 때문에 한 디렉터리에서 device용과 simulator용을 번갈아가며 컴파일하게 되면 어려운 점이 발생할 수 있습니다. 저의 경우를 예를 들자면 다음과 같이 디렉터리를 구성하였습니다.

drwxr-xr-x 21 HoTaeWang staff 714 10 6 14:16 Qt-BuildiOS-device/
drwxr-xr-x 21 HoTaeWang staff 714 10 6 14:33 Qt-BuildiOS-simulator/
drwxr-xr-x 36 HoTaeWang staff 1224 10 6 14:27 qt/

Configure 파일 만들기

Qt-BuildiOS-device 폴더에는 다음과 같은 Qt-iOS-device.sh 셀스크립트를 만들었습니다.

  1. !/bin/sh

../qt/configure -qpa -xplatform qpa/macx-iphonedevice-g++ -arch armv7 -no-neon -developer-build -release -opengl es2 -no-accessibility -no-qt3support -no-multimedia -no-phonon-backend -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations

해당 셀스크립트 실행

# . ./Qt-iOS-device.sh
# make -j4
-j(n) option은 자신의 CPU의 성능에 따라 선택할 

UIKit plugin compile 하기

# cd src/plugins/platforms/uikit
# make

Qt-BuildiOS-simulator 폴더에는 다음과 같은 Qt-iOS-simulator.sh 셀스크립트를 만들었습니다.

#!/bin/sh

../qt/configure -qpa -xplatform qpa/macx-iphonesimulator-g++ -arch i386 -developer-build -release -opengl es2 -no-accessibility -no-qt3support -no-multimedia -no-phonon-backend -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations

해당 셀스크립트 실행

# . ./Qt-iOS-simulator.sh
# make -j4
-j(n) option은 자신의 CPU 성능에 따라 선택할 

UIKit plugin compile 하기

# cd src/plugins/platforms/uikit
# make

Qt와 UIKit plugin 까지 compile이 성공하였다면 Qt for iOS 세상에 들어올 준비가 모두 끝난 것이다.

다음으로 해야 할 일은 XCode 4를 실행 시키고 qt/src/plugins/platforms/uikit/examples에서 XCode project를 열어 실행시키면 된다. XCode Toolbar에서 iPhone Simulator 4.3/iPad Simulator 4.3을 선택하고 Run Key를 누르면 아래와 같은 동영상을 확인 하실 수 있을 것이다. https://www.youtube.com/watch?v=glv_E3KOYuA

XCode 4의 다른 Project를 만들고 싶다면 https://qt.gitorious.org/qt/qt/blobs/4.8/src/plugins/platforms/uikit/README 를 참조해서 새롭게 만들 수 있습니다.

긴글 읽어 주셔서 감사합니다. 수정 해야 하거나 조금 더 가르침을 주실 사항이 있으시면 언제든지 comment나 e-mail 주십시요.