If I build a Qt/qmake sample project (in my case the "analog clock" example) and deploy it to a device running iOS 7.1 everything goes smooth: the app executes flawlessly on the device. Chapeau - the folks from digia did a formidable job to integrate the ios toolchain into their Qt workflow.
However, if I translate the qmake project into a CMake project, things don't go that smooth anymore. I've attached the analog clock example from the Qt-5.3.1 release (see below) where I added a CMakeLists.txt and a script that runs CMake to generate an XCode project for iOS. The project compiles and even links (I had to add some additional link libraries, see CMake source file). Yay.
But here's the trap: The app crashes at run-time with the following error message:
Error: Failed to load platform plugin “ios”
As a comment in this thread states one has to "force load" libqios via the project settings. Doing this didn't improve the situation much, it only changed the error message to:
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 have two questions:
- Does anyone have an idea what the problem is with the run-time errors? I know that qmake (and the corresponding ios mkspecs) do quite some magic. But how to translate that to CMake?
- Why do I have to link several libs (harfbuzzng, qios, libpng, and several iOS frameworks) manually to my target? Shouldn't find_package(Qt5 ...) do this job for me?
Here is the link to a zip file containing my Qt-CMake project. The Qt version I'm using is Qt-5.3.1 for iOS.
Edit: I found out that the qmake sample doesn't work just like this if you tear it out of the Qt examples folder structure. Look at the Qt example directly: path/to/Qt/examples/widgets/widgets/analogclock.