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

Adding -ObjC linking flag breaks iOS build

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8, 6.9
    • None
    • iOS/tvOS/watchOS

    Description

      Since Qt 6.8 it's no longer possible to compile iOS project with -ObjC flag because of the compilation error 

      duplicate symbol '_OBJC_METACLASS_$_WeakPointerLifetimeTracker' in:
          /Users/ncuxer/Qt/6.9.0/ios/lib/QtCore.framework/QtCore_debug[arm64][166](qcore_mac.mm.o)
          /Users/ncuxer/Qt/6.9.0/ios/lib/QtCore.framework/QtCore_debug[arm64][166](qcore_mac.mm.o)
          /Users/ncuxer/Qt/6.9.0/ios/lib/QtCore.framework/QtCore_debug[arm64][166](qcore_mac.mm.o)
          /Users/ncuxer/Qt/6.9.0/ios/lib/QtCore.framework/QtCore_debug[arm64][166](qcore_mac.mm.o)

      It happens because there are multiple /Users/ncuxer/Qt/6.9.0/ios/lib/QtCore.framework/QtCore_debug entries in "Other Linker flags" in Xcode "Build settings", and ObjC flag causes to load and link symbols from every entry.

      It works well in Qt 6.7.3 still, I don't know why exactly but it most probably because before Qt6.8 Qt was linked statically, not as frameworks, and it affects how linker behaves.

      You can easily reproduce the issue in any iOS build by adding ObjC flag. For example I've applied this flag to core/permission Qt 6.9 example and attached zip file, but you can do the same with 6.7 to compare the result.

      It's still possible to build the iOS version if you go to xcode settings and remove one duplicated entry manually.

      QtMultimedia_debug library also causes duplicate symbols issue 

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-135978
          # Subject Branch Project Status CR V

          Activity

            People

              qtbuildsystem Qt Build System Team
              ncuxer Sergey Gavrushkin
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change