Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-105006

iOS archive builds fail with qt_add_qml_module()s in static libs

    XMLWordPrintable

Details

    • iOS/tvOS/watchOS
    • 8bdc39ed36 (qt/qtdoc/dev) 8bdc39ed36 (qt/tqtc-qtdoc/dev) ec733f6afc (qt/qtdoc/6.4) ec733f6afc (qt/tqtc-qtdoc/6.4) ec733f6afc (qt/tqtc-qtdoc/6.4.0), 5c3f01ece (tqtc/lts-6.2)

    Description

      This is on macOS 12.4, XCode 13.4.1, using Qt 6.4.0-beta2 and cmake 3.23.2 from the Qt Installer

      The attached example is just the basic QtCreator template with the CMakeList.txt extended a bit:

      Main.qml is added to a "Mobile" qml module, which lives in static lib mobile_module and this one in turn gets linked to the app.

      This setup may not make much sense for this simple example, but the problem comes from a much bigger app, which has 4 separate QML modules, each with its own URI and import path, all linked together statically into the final app binary.

      Now, building and running this on the simulator or an iOS device works perfectly fine.

      I have then added a custom target named archive, which creates a so called "archive" build via xcode and this archive build is required to create a package that can be uploaded to the appstore and this is where the build breaks.

      To trigger the bug:

      • setup a "Release" build in QtCreator
      • do a rm -rf <the build dir> anytime you fiddle around with stuff... we are dealing with files being pulled from wrong directories, so better be safe than sorry (ask me why I know )
      • build the archive target (ONLY archive, please uncheck the ALL target)

      You get something like this:

      clang: error: no such file or directory: '<build-dir>/mobile_module_resources_1.build/Objects-normal/x86_64/mocs_compilation.o'
      clang: error: no such file or directory: '<build-dir>/mobile_module_resources_1.build/Objects-normal/x86_64/qrc_qmake_Mobile.o'
      clang: error: no such file or directory: '<build-dir>/mobile_module_qmlcache.build/Objects-normal/x86_64/mocs_compilation.o'
      clang: error: no such file or directory: '<build-dir>/mobile_module_qmlcache.build/Objects-normal/x86_64/mobile_module_qmlcache_loader.o'
      clang: error: no such file or directory: '<build-dir>/mobile_module_resources_2.build/Objects-normal/x86_64/mocs_compilation.o'
      clang: error: no such file or directory: '<build-dir>/mobile_module_resources_2.build/Objects-normal/x86_64/qrc_mobile_module_raw_qml_0.o'
      
      clang: error: no such file or directory: '<build-dir>/Release-iphonesimulator/libmobile_module.a'
      
      Command Ld failed with a nonzero exit code  

      What is happening here is that this archive build should be completely self-contained inside ${CMAKE_BINARY_DIR}/derivedData, but cmake is somehow trying to pull files in from the standard build directories.
      All the files (.o and .a) the linker complains about have been created in the correct locations inside the derivedData dir, but the linker is being instructed to pull them from locations where they would be in a standard Release build.

      Working around the .a not being found is possible by forcing a common folder for static libs via

      set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library) 

      but I consider this a hack, plus it has to be done BEFORE defining any static lib target.

      But that still leaves us with all the moc, resource, qml and qmlcache .o files, which aren't part of a static lib, but an object library and I couldn't find a cmake setting to force an OUTPUT_DIRECTORY for these as well)

      The workaround I had to use in the actual project where I ran into this issue is this ugly script that creates a bunch of symlinks: it does do the trick of letting the archive build succeed, but that's not a viable long term solution.

      https://github.com/rgriebl/brickstore/blob/02b005f6013999a34761434e0108e5e697c1bb3c/scripts/fix-ios-archive-build.sh

       

      PS: Just for the record: removing NO_PLUGIN and doing the plugin registration manually doesn't make a difference.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              alexandru.croitor Alexandru Croitor
              rgriebl Robert Griebl
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes