0

I am using Xcode 9.4.1 and Qt 5.11 and currently have a working .pro file for running my Qt application on iOS.

Just for fun I wanted to try qbs as I really like the syntax. I have now tried to write a .qbs file that mirrors my .pro file.

Everything compiles fine, but when linking I get the following issues when trying to run the ios-simulator (and similar for ios, but with different architecture):

Undefined symbols for architecture x86_64:
  "_AVAudioSessionCategoryPlayback", referenced from:
      -[MyClass enable] in MediaPlayer.mm.o
  "_MPMediaItemPropertyArtist", referenced from:
      -[MyClass setMediaInfo:artist:] in MediaPlayer.mm.o
  "_MPMediaItemPropertyTitle", referenced from:
      -[MyClass setMediaInfo:artist:] in MediaPlayer.mm.o
  "_OBJC_CLASS_$_AVAudioSession", referenced from:
      objc-class-ref in MediaPlayer.mm.o
  "_OBJC_CLASS_$_MPNowPlayingInfoCenter", referenced from:
      objc-class-ref in MediaPlayer.mm.o
  "_OBJC_CLASS_$_MPRemoteCommandCenter", referenced from:
      objc-class-ref in MediaPlayer.mm.o
ld: symbol(s) not found for architecture x86_64

What I have done in my .pro file to include frameworks are:

LIBS += -framework MediaPlayer -framework AVFoundation

And for the .qbs I have written:

cpp.frameworks: base.concat(["MediaPlayer", "AVFoundation"])

also tried:

cpp.frameworkPaths: base.concat(["/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks"])
cpp.frameworks: base.concat(["MediaPlayer", "AVFoundation"])

and:

cpp.frameworks: ["MediaPlayer", "AVFoundation"]

I'm have been stuck with this problem for hours now and hard to find similar usage of qbs files online and on Github. Anyone who know why the linker can't find the frameworks?

EDIT

I tried creating a new project using qbs and I get similar issues. Here is the full build log:

19:12:55: Running steps for project Test...
linking Test (x86_64, debug)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -Wl,-arch,x86_64,-ios_simulator_version_min,10.0,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk,-e,_qt_main_wrapper -stdlib=libc++ -L/Users/john/Qt/5.11.1/ios/lib -L/Users/john/Qt/5.11.1/ios/plugins/platforms -target x86_64-apple-ios10.0-macho -o /Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/.tmp/Test /Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/3a52ce780950d4d9/main.cpp.o /Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/3a52ce780950d4d9/qrc_qml.cpp.o -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Foundation -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework CoreGraphics -framework Foundation -framework OpenGLES -framework CoreText -framework UIKit -framework QuartzCore -framework CoreText -framework CoreGraphics -framework Foundation -framework CoreFoundation -framework AudioToolbox -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreGraphics -framework OpenGLES -framework CoreText -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework OpenGLES /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lz -lm -lm -lz -lqtpcre2_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Gui_debug.a -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug -lqtlibpng_debug -lqtharfbuzz_debug -lz /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug -lz /Users/john/Qt/5.11.1/ios/lib/libQt5Qml_debug.a @/Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/plugins.list.d -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Quick_debug.a -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Qml_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Gui_debug.a -lqtlibpng_debug -lqtharfbuzz_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Foundation -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework CoreGraphics -framework Foundation -framework OpenGLES -framework CoreText -framework UIKit -framework QuartzCore -framework CoreText -framework CoreGraphics -framework Foundation -framework CoreFoundation -framework AudioToolbox -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreGraphics -framework OpenGLES -framework CoreText -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework OpenGLES
Undefined symbols for architecture x86_64:
  "_qt_main_wrapper", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Process failed with exit code 1.
The following products could not be built for configuration qtc_Qt_5_11_1_for_iOS_Simulator_Debug:
Test {"architecture":"x86_64","buildVariant":"debug"}
Error while building/deploying project Test (kit: Qt 5.11.1 for iOS Simulator)
When executing step "Qbs Build"
19:12:57: Elapsed time: 00:02.

I installed Xcode 9.4.1 then Qt 5.11 for macos and ios.

EDIT2

It builds fine on desktop, but when I switch to ios or ios-simulator I get this warning in my .qbs file:

enter image description here

EDIT3

Here are my qbs settings for the relevant kit:

enter image description here

uniquenamehere
  • 1,869
  • 3
  • 31
  • 60
  • Along with the error message, qbs also shows you the linker command line. Compare it to the one you get with your qmake project. Presumably that one has more frameworks and/or libraries that it pulls in indirectly (perhaps from some Qt prf file). – Christian Kandeler Jul 16 '18 at 20:40
  • @ChristianKandeler Thank you for your reply. I looked at the linker and both the correct paths and frameworks are mentioned. To try to debug this a bit more I created a new Qt Quick "Empty" project and tried to build it for iOS simulator and I get similar issues with undefined symbols for architecture. I will update over with full build log. – uniquenamehere Jul 18 '18 at 13:46

1 Answers1

1

AFAIK, the _qt_main_wrapper symbol comes in via the platform plugin. So you could add the dependency yourself:

Depends { name: "Qt.qios" } // I think that's the name...

Or you could use the QtGuiApplication item (instead of Product or CppApplication or whatever you are using now), which takes care of this automatically.

  • This helps getting the test application to build. I do still get warnings. I added a picture above so you can se the warnings and how my .qbs file looks like. Even though it builds I can't run the application as it does not find any executable. Am I missing something? – uniquenamehere Jul 18 '18 at 20:09
  • Just upgraded to Qt Creator 4.7 (Qbs 1.12.0) just to see if it helps, but same issue. I also tried creating a new empty Qt Quick application project, but same issues. I add `Depends { name: "Qt.qios" }` and it builds, but it can't find any Qt modules and I think therefore does not create an executable/bundle. I added a screenshot of my qbs settings above. – uniquenamehere Jul 18 '18 at 20:16
  • Tried the helloworld-qt example in the qbs repo and same issue there as well. Either there is something wrong with my setup or there is something very flawed with qbs. I both believe and hope its the first :) – uniquenamehere Jul 18 '18 at 20:38
  • For iOS targets, qbs by default tries to build for two architectures. In the case of ios-simulator, these are x86 and x86_64. However, only one of these is supported by the Qt installation in your kit, so loading the Qt modules fails for the other one. You can see that in your screenshot: The product is present twice, with the x86 instance greyed out. You can get rid of the warning by overwriting the default set of architectures: "qbs.architectures: 'x86_64'". As for the failure to run, that's a long-standing Qt Creator issue -- iOS development is fully supported only with qmake. – Christian Kandeler Jul 19 '18 at 11:48
  • Thank you for explaining about the architectures. I were able to remove the warning and choose the relevant architecture. If I understood you correctly, iOS development is only fully supported with qmake if you use Qt Creator? Does this mean that qbs support iOS, but Qt Creator is lacking some integration? So it's possible to build for iOS on the command line? – uniquenamehere Jul 19 '18 at 13:15
  • And final question. If qbs is lacking iOS support, is there a road map or any estimates on when it will receive the same level of support as qmake? – uniquenamehere Jul 19 '18 at 13:22
  • qbs itself supports building for iOS, on the command line and in Qt Creator (as you said, you were able to build, but Qt Creator did not offer you to run the project). This qmake dependency issue is tracked here: https://bugreports.qt.io/browse/QTCREATORBUG-14858. – Christian Kandeler Jul 20 '18 at 07:57
  • I see. Thank you so much Christian :) – uniquenamehere Jul 20 '18 at 14:35