Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Build Qt from source for iOS arm64 simulator (on M1)

Build Qt from source for iOS arm64 simulator (on M1)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ad1170A Offline
    ad1170A Offline
    ad1170
    wrote on last edited by ad1170
    #1

    Hi folks,
    is it possible to build Qt6 (6.2.2) from source for the arm64 iOS simulator?

    Generator Xcode:
    Until now, the configure tool fails with the following error

    error: unable to resolve product type 'com.apple.product-type.tool' for platform 'iphonesimulator' (in target 'architecture_test' from project 'arch')
    

    I have made an additional makespec which set the arm64 for the simulator too.
    The last try was to change the architecture test in the QtAutoDetect.cmake:210 to set(osx_architectures "arm64").
    But it didn't help.

    Trying to build x86_64 simulator also fails with the same message.
    When is use the default (ninja) generator, the error message is

    Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
    

    The Qt6CoreTools_DIR is set to ~/Qt/6.2.2/macos/lib/cmake/Qt6CoreTools

    Here is the build script:

    #!/bin/zsh
    cd build
    
    MY_QT_PATH=/Users/user/Qt/6.2.3
    MY_ARCH=arm64
    
    export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/Library/Apple/usr/bin:/Users/user/Qt/Tools/CMake//CMake.app/Contents/MacOS/CMake:/Users/user/Qt/Tools/CMake/CMake.app/Contents/bin:/Users/user/Qt/Tools/Ninja
    
    export QT_HOST_PATH=$MY_QT_PATH/Qt/6.2.2/macos
    export QT_HOST_PATH_CMAKE_DIR=$MY_QT_PATH/macos/lib/cmake
    export QT_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6
    
    export CMAKE_OSX_ARCHITECTURES=$MY_ARCH
    export CMAKE_OSX_SYSROOT=iphonesimulator
    export CMAKE_PREFIX_PATH=$MY_QT_PATH/ios
    export CMAKE_TOOLCHAIN_FILE=$MY_QT_PATH/ios/lib/cmake/Qt6/QtToolchainHelpers.cmake
    
    export Qt6HostInfo_DIR=$MY_QT_PATH/macos/lib/cmake/Qt6HostInfo
    export Qt6Bluetooth_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Bluetooth
    export Qt6BundledPcre2_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6BundledPcre2
    export Qt6Concurrent_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Concurrent
    export Qt6CorePrivate_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Core
    export Qt6CoreTools_DIR=$MY_QT_PATH/macos/lib/cmake/Qt6CoreTools
    export Qt6Core_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Core
    export Qt6EntryPointPrivate_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6EntryPointPrivate
    export Qt6NetworkPrivate_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Network
    export Qt6Network_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Network
    export Qt6_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6
    
    ../configure -platform macx-ios-clang-arm64 -DCMAKE_OSX_ARCHITECTURES=$MY_ARCH -release -prefix $MY_QT_PATH-Simulator-$MY_ARCH \ 
                 -extprefix $MY_QT_PATH-Simulator-$MY_ARCH -cmake-generator Xcode -sdk iphonesimulator -qt-host-path $MY_QT_PATH/ios \ 
                 -nomake tests -- -DCMAKE_OSX_ARCHITECTURES=$MY_ARCH -DQT_FORCE_MACOS_ALL_ARCHES_$MY_ARCH=TRUE -DCMAKE_SYSTEM_NAME=iOS \
                 --trace-expand --trace-redirect=log.txt
    
    

    Has anyone experience building qt 6 on mac?

    Thanks.

    ad1170A 1 Reply Last reply
    1
    • ad1170A ad1170

      Hi folks,
      is it possible to build Qt6 (6.2.2) from source for the arm64 iOS simulator?

      Generator Xcode:
      Until now, the configure tool fails with the following error

      error: unable to resolve product type 'com.apple.product-type.tool' for platform 'iphonesimulator' (in target 'architecture_test' from project 'arch')
      

      I have made an additional makespec which set the arm64 for the simulator too.
      The last try was to change the architecture test in the QtAutoDetect.cmake:210 to set(osx_architectures "arm64").
      But it didn't help.

      Trying to build x86_64 simulator also fails with the same message.
      When is use the default (ninja) generator, the error message is

      Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
      

      The Qt6CoreTools_DIR is set to ~/Qt/6.2.2/macos/lib/cmake/Qt6CoreTools

      Here is the build script:

      #!/bin/zsh
      cd build
      
      MY_QT_PATH=/Users/user/Qt/6.2.3
      MY_ARCH=arm64
      
      export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/Library/Apple/usr/bin:/Users/user/Qt/Tools/CMake//CMake.app/Contents/MacOS/CMake:/Users/user/Qt/Tools/CMake/CMake.app/Contents/bin:/Users/user/Qt/Tools/Ninja
      
      export QT_HOST_PATH=$MY_QT_PATH/Qt/6.2.2/macos
      export QT_HOST_PATH_CMAKE_DIR=$MY_QT_PATH/macos/lib/cmake
      export QT_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6
      
      export CMAKE_OSX_ARCHITECTURES=$MY_ARCH
      export CMAKE_OSX_SYSROOT=iphonesimulator
      export CMAKE_PREFIX_PATH=$MY_QT_PATH/ios
      export CMAKE_TOOLCHAIN_FILE=$MY_QT_PATH/ios/lib/cmake/Qt6/QtToolchainHelpers.cmake
      
      export Qt6HostInfo_DIR=$MY_QT_PATH/macos/lib/cmake/Qt6HostInfo
      export Qt6Bluetooth_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Bluetooth
      export Qt6BundledPcre2_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6BundledPcre2
      export Qt6Concurrent_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Concurrent
      export Qt6CorePrivate_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Core
      export Qt6CoreTools_DIR=$MY_QT_PATH/macos/lib/cmake/Qt6CoreTools
      export Qt6Core_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Core
      export Qt6EntryPointPrivate_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6EntryPointPrivate
      export Qt6NetworkPrivate_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Network
      export Qt6Network_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6Network
      export Qt6_DIR=$MY_QT_PATH/ios/lib/cmake/Qt6
      
      ../configure -platform macx-ios-clang-arm64 -DCMAKE_OSX_ARCHITECTURES=$MY_ARCH -release -prefix $MY_QT_PATH-Simulator-$MY_ARCH \ 
                   -extprefix $MY_QT_PATH-Simulator-$MY_ARCH -cmake-generator Xcode -sdk iphonesimulator -qt-host-path $MY_QT_PATH/ios \ 
                   -nomake tests -- -DCMAKE_OSX_ARCHITECTURES=$MY_ARCH -DQT_FORCE_MACOS_ALL_ARCHES_$MY_ARCH=TRUE -DCMAKE_SYSTEM_NAME=iOS \
                   --trace-expand --trace-redirect=log.txt
      
      

      Has anyone experience building qt 6 on mac?

      Thanks.

      ad1170A Offline
      ad1170A Offline
      ad1170
      wrote on last edited by ad1170
      #2

      @ad1170 Meanwhile, we have solved the issue and fond a configuration that build Qt for iOS simulator for the arm64 and x86_64 architecture. The last solution is based on the qt-everywhere-src-6.2.3 and use the "macos" directory an installed Qt6.2.3 (via installer).

      1. Install the Qt6.2.3 via the online installer
      2. Download and extract the qt-everywhere-src-6.2.3 (https://download.qt.io/official_releases/qt/6.2/6.2.3/single/)
      3. modify (or add a new) makespec for macx-ios-clang and add arm64 for the iOS simulator target (in qt-everywhere-src-6.2.3\qtbase\mkspecs)
      4. make a build folder and change in to this folder
      5. run the configure tool from qt-everywhere with following command line

      YOUR_QT_DEST_PATH and PATH_TO_QT623 are placeholders, replace them according to your needs / environment.

      ../configure -release -static -xplatform macx-ios-clang -sdk iphonesimulator \
      -prefix YOUR_QT_DEST_PATH -extprefix YOUR_QT_DEST_PATH -qt-host-path PATH_TO_QT623/macos \
      -DCMAKE_OSX_SYSROOT="iphonesimulator" -- -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
      

      Run cmake --build . --parallel to build the Qt library's and cmake . --install to install this version in to your YOUR_QT_DEST_PATH.

      Special thank goes to Patrick, he has made it possible.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved