Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Running a Qt app on iOS device from a Mac M1 / Apple silicon



  • I just bought a Mac Mini M1, installed XCode and Qt 6.0.1 for iOS. I created an empty Qt Quick project and tried to compile it to my iOS device (which shows up as "Ready to use"). It seems it can not compile out of the box.

    The build output:

    Running /Applications/CMake.app/Contents/bin/cmake -S /Users/johndoe/git/qt6iostest -B /private/var/folders/w1/phnpqk3d6tx3dg6x56xrlp1w0000gn/T/QtCreator-zJFCpa/qtc-cmake-ENXAuLvG in /private/var/folders/w1/phnpqk3d6tx3dg6x56xrlp1w0000gn/T/QtCreator-zJFCpa/qtc-cmake-ENXAuLvG.
    -- The CXX compiler identification is AppleClang 12.0.0.12000032
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - failed
    -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
    -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - broken
    CMake Error at /Applications/CMake.app/Contents/share/cmake-3.19/Modules/CMakeTestCXXCompiler.cmake:59 (message):
      The C++ compiler
    
        "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
    
      is not able to compile a simple test program.
    
      It fails with the following output:
    
        Change Dir: /private/var/folders/w1/phnpqk3d6tx3dg6x56xrlp1w0000gn/T/QtCreator-zJFCpa/qtc-cmake-ENXAuLvG/CMakeFiles/CMakeTmp
        
        Run Build Command(s):/Users/johndoe/Qt/Tools/Ninja/ninja cmTC_b5e39 && [1/2] Building CXX object CMakeFiles/cmTC_b5e39.dir/testCXXCompiler.cxx.o
        [2/2] Linking CXX executable cmTC_b5e39
        FAILED: cmTC_b5e39 
        : && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ --target=aarch64-apple-darwin20.1.0 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/cmTC_b5e39.dir/testCXXCompiler.cxx.o -o cmTC_b5e39   && :
        ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libc++.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libc++.tbd (4 slices)
        ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libSystem.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libSystem.tbd (4 slices)
        ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
        ninja: build stopped: subcommand failed.
    
      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:3 (project)
    
    -- Configuring incomplete, errors occurred!
    See also "/private/var/folders/w1/phnpqk3d6tx3dg6x56xrlp1w0000gn/T/QtCreator-zJFCpa/qtc-cmake-ENXAuLvG/CMakeFiles/CMakeOutput.log".
    See also "/private/var/folders/w1/phnpqk3d6tx3dg6x56xrlp1w0000gn/T/QtCreator-zJFCpa/qtc-cmake-ENXAuLvG/CMakeFiles/CMakeError.log".
    CMake process exited with exit code 1.
    Elapsed time: 00:01.
    

    I'm sure there's an issue due to XCode being installed as a native ARM app and Qt is emulated with Rosetta 2. Has anyone been able to make this compile and run?


  • Moderators

    @Hisni it's not supported yet

    you can follow the progress here:
    https://bugreports.qt.io/browse/QTBUG-85279

    ATA, apparently Qt 6.2


  • Moderators

    @J-Hilk said in Running a Qt app on iOS device from a Mac M1 / Apple silicon:

    @Hisni it's not supported yet

    you can follow the progress here:
    https://bugreports.qt.io/browse/QTBUG-85279

    ATA, apparently Qt 6.2

    No, that's not what OP is asking about. They ask about running iOS from M1 mac.

    Btw. Qt 6.0.0 works on M1, compilation works etc. when you target desktop.


  • Moderators

    @sierdzio
    fair enough,

    I'm not sure if the precompiled libs for iOS will work then.
    I assume the cross compiler for M1 -> iOS is incompatible with the downloadable libs that were maid with the cross compiler for Intel-> iOS

    right ?


  • Moderators

    @J-Hilk said in Running a Qt app on iOS device from a Mac M1 / Apple silicon:

    @sierdzio
    fair enough,

    I'm not sure if the precompiled libs for iOS will work then.
    I assume the cross compiler for M1 -> iOS is incompatible with the downloadable libs that were maid with the cross compiler for Intel-> iOS

    right ?

    Possible. I have not tried.



  • @J-Hilk said in Running a Qt app on iOS device from a Mac M1 / Apple silicon:

    I assume the cross compiler for M1 -> iOS is incompatible with the downloadable libs that were maid with the cross compiler for Intel-> iOS

    I don't see a technical reason why this should be. I assume the source for the compiler to be basically the same. Therefore, the output of the compiler should be the same for M1 and Intel.

    However, having a look at the error output: I do see --target=aarch64-apple-darwin20.1.0 in the parameters for clang++ (assuming this means for iOS). At the same time there is also -arch x86_64. All the following errors also indicate that you are compiling an x86 binary. The errors are that the libraries for iOS don't have versions for x86. This is indeed true. It could be that there is a bug here in Qt's cmake configuration.

    I don't have an M1 Mac and I also never compiled for iOS. Maybe someone else can figure it out from here.


Log in to reply