5.2 and iOS - let's get this straight



  • I was ecstatic to see that 5.2 will support "production" iOS development. I quickly downloaded the 5.2 beta and .. was quickly lost.

    So, questions! Please answer if you actually know the answers and have successfully built and run code using the 5.2 beta!

    What are the supported workflows?

    With earlier versions qmake built Xcode project files and developers used XCode to build/deploy/debug. With 5.2 Creator can supposedly build directly. I found that this is disabled by default and that to enable it you need to go to "About Plugins" and check the iOS option. Then, no iOS "kits" are configured. I got "iphoneos-clang" to auto-detect by poking around and manually adding something (compiler? kit?).

    Can qmake still generate Xcode project files? Where are instructions for configuring Creator with the "kits" distributed with the beta?

    QtQuick 2.0?

    Most info online indicates that only 1.0 is supported.. that was true for older versions because V8 was not compatible with the App Store. But that's been fixed. And I see 'quick2' static libraries in the ios_armv7 tree..

    Any suggestions greatly appreciated!

    Tyler



  • Hi,
    same for me: I did create kits, one with complier for device and one for simulator by manually selecting the corresponding compiler. Then I could create the xproj files for a simple test app by selecting those kits. QtCreator has successfully created folders ready for compilation with Xcode.
    Then, I had no luck compiling those in Xcode due to an unknown Xlinker flag. I am using the latest Xcode and targeting iOS7. Today I will try it again but I think it would be nice to have a "How-To".
    Best,
    Roger



  • [quote author="Roger1977" date="1383029074"]Hi,
    Then I could create the xproj files for a simple test app by selecting those kits. QtCreator has successfully created folders ready for compilation with Xcode. [/quote]

    How did you create the xproj files? I've managed to get a test app building but not yet running by creating an Xcode project myself..



  • Oops, I was able to create the Xcode project by running qmake.. didn't notice it before. Now I face the same problem with both projects:

    "Error: You are creating QApplication before calling UIApplicationMain.
    If you are writing a native iOS application, and only want to use Qt for
    parts of the application, a good place to create QApplication is from within
    'applicationDidFinishLaunching' inside your UIApplication delegate."



  • I think, this is maybe due to your app. First give a try with a "empty" (simple Hello-World) app. for testing the toolchain.



  • One project was created as a "Qt Quick 1 Application (existing types)" using Creator and the other is an empty Xcode project. Both are exiting with the above error on the first line of main(), QApplication(argc,argv).

    I've also tried DECLARATIVE_EXAMPLE_MAIN as used in the "maroon" and other examples tagged with "android," but no go. It seems something has changed in 5.2 and just creating a QGuiApplication is not the way to do a cross platform app. (The error message suggests that using Qt for part of the application is supported, which is promising, though not my original goal..)

    That's enough for today.. I'll have to fight through the beta-ness another day...



  • Hi
    I was able to build and run code using 5.2 beta, almost without any problems. Most of the standard Qt example projects were also built without any modifications or something.
    Look here for more info:
    http://doc-snapshot.qt-project.org/qdoc/ios-support.html

    You'll see it's a pretty much easy 3 -step process

    1. Do the normal codings in Qt creator
    2. Run QMake to create XCode project
    3. Build and Run using XCode for iOS


  • There's also this link which is very useful.
    http://stackoverflow.com/questions/17477165/creating-qt-5-1-apps-for-ios

    Don't pay attention to 5.1 title, the same goes for 5.2



  • Hi, thanks for the links amahta. Do you know of any particular example which works?

    I can now build and run apps, but they quit immediately with the error given above.

    Usually you would create a QApplication in main(), but that doesn't work for me.



  • Hmm. Lets see. I suggest you try the most simple application possible.
    Just a hello world.
    Try this example which I'm 100% sure it works :) (And as I said, most of the default Qt examples work and there are just a few that does not)

    @
    #include <QApplication>
    #include <QLabel>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QLabel l;
    l.setText("Hello World");
    l.show();
    return a.exec();
    }
    @



  • In case you're wondering what the pro file looks like, here it is:
    @
    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = Hello_World
    TEMPLATE = app
    SOURCES += main.cpp
    @



  • Hi amahta, thanks again for the excellent sample!

    Unfortunately, same error:

    "Error: You are creating QApplication before calling UIApplicationMain.
    If you are writing a native iOS application, and only want to use Qt for
    parts of the application, a good place to create QApplication is from within
    'applicationDidFinishLaunching' inside your UIApplication delegate."

    I created main.cpp and a .pro file with the contents above, ran qmake from the ios_armv7 tree in 5.2 beta1, then built with Xcode 5 against the 7.0 SDK for my iPhone 5s.

    Did you build Qt from source or use the precompiled version? (I'm using the precompiled version..)



  • Unfortunately I only intended to test on Simulator (cause I don't have an iPhone), that is why I didn't use the precompiled version because it does not come with Simulator support. Also my XCode version is 4.6.2 and SDK is 6.1.

    Overall I don't suppose differences in version are the cause of this (Specially because yours is higher than mine :) ) but I suggest you also build from the source and skip all complications. At least after that if the problem persists we can start looking around for other solutions.



  • Hello,

    I just start developing iOS app with the Qt framework with the Qt beta 5.2 version and I am using Xcode 4.6.3 and SDK 6.1.3.

    Maybe you will find the experiences I made while installing and configuring the Qt Creator IDE helpful.

    I started with downloading and installing the offline installer called qt-mac-opensource-5.2.0-beta1-ios-x86_64-offline.dmg

    After installation and starting Qt Creator I had to turn on the iOS support like you mentioned in your post above.
    To configure kits, compilers and so on I had to manually add the Qt Versions which are installed but not configured in Qt Creator. To configure them, you have to add a path to the according qmake file under Preferences->Build&Run->Qt Versions. You will have to add ~/Qt5.2.0/5.2.0-beta1/ios_x86/bin/qmake for iOS simulator and ~/Qt5.2.0/5.2.0-beta1/ios_armv7/bin/qmake for iOS devices. Compilers and Kit are auto-detected afterwards.

    Then I created a new project with the 'Qt Quick 1 Application (Built-in Types)' - template. To ensure your qml file can be located in the resulting iOS app, you have to create a Qt resource file and add a prefix and the qml file (main.qml) beneath the prefix. In the main.cpp you make sure the qml file is loaded with viewer.setSource(QUrl("qrc:/<path_to_qml_file>"));

    Don't forget running qmake now ;-)

    The steps left before deployment to a device are configuring your device and building and deploying to it.

    There is a how-to which describes how to configure your device ("Developing iOS":http://doc-snapshot.qt-project.org/qtcreator-3.0/creator-developing-ios.html). There is nothing really new for someone used to develop iOS apps but there is one important thing to note: You have to add an Xcode build step by selecting Add Build Step > xcodebuild. You find this under Projects -> Build&Run when you have an Project opened in Qt Creator.

    Your device should be detected (Preferences->Devices) and it should its current state should be marked with a green dot. Building and deploying can both be done with Qt Creator now. Starting the app takes a while so just wait a little bit.

    Unfortunately there is a known bug about using QtQuick 2. Its related to statically binding of libraries. More info about this one you can find here: "QTBUG-28357":https://bugreports.qt-project.org/browse/QTBUG-28357

    Maybe someone can find a workaround for this. Otherwise we will have to wait for the next minor version.

    Regards

    DaBoba



  • Thanks DaBoba for the hint "adding Build Step > xcodebuild". The "Hello World" App is running from QtCreator on iOS Simulator.
    Anyway, when I try to compile the project within XCode I get XLinker errors.



  • Hi all,

    maybe i can append my problem here :-)

    I downloaded the beta1-ios-x86_64-offline package and installed it. I have xcode 5 installed.
    But unfortunately there is no ios kit under Preferences->Build and Run. What can i do to create a kit?

    Thank you!

    regards



  • @ dualfaces : Under Projects (or Extra-> Settings) you can manage Kits. There ("Build and Run" - Settings) you have to select the Qt Version by choosing qmake from the ios folder inside Qt installation path. Make sure you have the Compiler also available (should be from the start). Then add a new Kit with the right Qt Version and the corresponding compiler.
    Hope this helps, otherwise I can give you more information.



  • Hi roger,

    thank you. I can chose the qmake version, but how to furhter specify the kit? Under Device type there is no ios device, further qt creator does not recognize my ipod touch, but it is connected and usable via xcode.

    I checked out the qt beta sources and built them like described here: http://stackoverflow.com/questions/17477165/creating-qt-5-1-apps-for-ios Everything works fine, the demo app is deployable and correctly executed on the ipod touch. Then i built the multimedia module and tried to run the audioinput and audiooutput example shipped with qt.
    On MAC they both run, but on the ipod no input or output device is found. That is really confusing, since i can't imagine noone tested this classes on an ios device. The ipod is running ios 7.0.2.

    Does someone have an idea on that?

    Regards!



  • I also tried setting Kits after I participated in this thread :)
    It seems much more efficient that building using XCode but I can't get rid of the red asterisk (!) sign beside "iphonesimulator-clang Qt 5.2.0 (ios_x86)" under Kits in Preferences and somehow I'm unable to Build & Run directly using QtCreator.
    Some timeout error for simulator is preventing my app from running.
    Any ideas anyone???



  • I was finally able to get things working using the Xcode projects generated by Creator/qmake.

    The problem on my system was that one script generated by Qt was not being executed in the correct directory. The script essentially renames main() to qt_main() so that a default main() defined by the Qt ios platform plugin is used instead. (The main() from Qt is defined as a weak symbol.)

    I had to add a line like this to the beginning of the "Qt Prelink" build phase script:

    @obj_dir=OBJECT_FILE_DIR_${CURRENT_VARIANT}; cd ${!obj_dir}/${CURRENT_ARCH}@

    Not sure if this problem is caused because of changes in Xcode 5 or something about my particular workspace configuration..

    Hope that helps someone else!



  • By the way, I also forgot to mention that my problem also got solved by a simple restart :)
    I installed prebuilt Qt5.2.0.beta1 for iOS (according to DaBobba's post in this thread) and I can develop and run iOS apps using QtCreator. This is pretty fast and efficient.

    [quote author="amahta" date="1383148049"]I also tried setting Kits after I participated in this thread :)
    It seems much more efficient that building using XCode but I can't get rid of the red asterisk (!) sign beside "iphonesimulator-clang Qt 5.2.0 (ios_x86)" under Kits in Preferences and somehow I'm unable to Build & Run directly using QtCreator.
    Some timeout error for simulator is preventing my app from running.
    Any ideas anyone???[/quote]



  • I have a question. So, I already have an xcode project that uses Qt 5.1 and now want to target iOS using Qt 5.2 beta. I made what I think are all the correct project tweaks, but I get the following error in qopengl.h

    #include <OpenGLES/ES2/gl.h> file not found.

    Has anyone seen this?



  • Never mind the ios kit - just have your Qt app ready and run qmake: ~/Qt5.2.0/5.2.0-rc1/ios/bin/qmake (replace the path with your install location ofc :p), then open the Xcode project file in Xcode and hit build.

    Just tried this with a QtQuick 2.0 app and it works - app runs very slowly, but works otherwise perfectly.

    • Matti

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.