QtCreator fails on MacOS SDK 11.1

Viewed 5001

I have Qt5 from brew in: /usr/local/Cellar/qt5/5.15.2/bin/

I use QtCreator 4.12.82.

I have MacOS Big Sur 11.1 with XCode installed in ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk.

When I create a new standard project in QtCreator I get the following error:

10:35:16: Running steps for project test2...
10:35:16: Starting: "/usr/local/Cellar/qt/5.15.2/bin/qmake" /Users/joefresna/VideoImageEdit/test2/test2.pro -spec macx-g++ CONFIG+=x86_64 CONFIG+=qtquickcompiler
Project WARNING: Qt has only been tested with version 10.15 of the platform SDK, you're using 11.0.
Project WARNING: This is an unsupported configuration. You may experience build issues, and by using
Project WARNING: the 11.0 SDK you are opting in to new features that Qt has not been prepared for.
Project WARNING: Please downgrade the SDK you use to build your app to version 10.15, or configure
Project WARNING: with CONFIG+=sdk_no_version_check when running qmake to silence this warning.
10:35:17: The process "/usr/local/Cellar/qt/5.15.2/bin/qmake" exited normally.
10:35:17: Starting: "/usr/bin/make" -f /Users/joefresna/VideoImageEdit/build-test2/Makefile qmake_all
/usr/local/Cellar/qt/5.15.2/mkspecs/features/mac/sdk.mk:22: *** ^.  Stop.
The platform SDK has been changed from version 11.0 to version 11.1.
This requires a fresh build. Please wipe the build directory completely,
including any .qmake.stash and .qmake.cache files generated by qmake.
10:35:20: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project test2 (kit: Qt 5.15)
When executing step "qmake"
10:35:20: Elapsed time: 00:04.```

(Note that even if I delete the build directory I still get the warning about wiping the directory)

The QtCreator Kit points to the qt installed via brew (indicated above). I tried to change the compilers in QtCreator > Projects > Manage Kits > Kits > Compiler and I tried both GCC and Clang from /usr/bin and from XCode, without success.

When I type xcodebuild -showsdks, I get:

iOS SDKs:
    iOS 14.4                        -sdk iphoneos14.4

iOS Simulator SDKs:
    Simulator - iOS 14.4            -sdk iphonesimulator14.4

macOS SDKs:
    DriverKit 20.2                  -sdk driverkit.macosx20.2
    macOS 11.1                      -sdk macosx11.1

tvOS SDKs:
    tvOS 14.3                       -sdk appletvos14.3

tvOS Simulator SDKs:
    Simulator - tvOS 14.3           -sdk appletvsimulator14.3

watchOS SDKs:
    watchOS 7.2                     -sdk watchos7.2

watchOS Simulator SDKs:
    Simulator - watchOS 7.2         -sdk watchsimulator7.2

Do you know how to solve this problem?

2 Answers

Install older Mac OS X SDK in newer Xcode

Updated, confirmed using XCode 12.4

https://github.com/phracker/MacOSX-SDKs hosts the direct SDK folders already extracted.

Find the version of XCode containing the desired SDK here: https://developer.apple.com/support/xcode/

Download the XCode version containing the desired SDK here: https://developer.apple.com/download/more/ or here: https://developer.apple.com/downloads/index.action

  1. Download the older XCode.

  2. After downloading mount the DMG file (or unpack the .xip file) and navigate to XCode.app

  3. Open the application by clicking Show Package Content

  4. Navigate to /Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

  5. Copy the MacOSX.sdk folder to a temporary location. Rename MacOSX.sdk to the same name as the link in step 4 (e.g. MacOSX10.15.sdk)

  6. Navigate to /Applications/XCode.app and click Show Package Content

  7. Navigate to /Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

  8. Paste the copied and renamed folder (MacOSX10.15.sdk).

  9. Restart XCode

  10. Then, the new SDK appears in the combo box in XCode: Preferences, Locations, Command Line Tools. Choose the one you want to use.

  11. Then, for all projects, open the shadow build directories and delete files named “.qmake.stash”, or in general “.qmake.*”. (Command-Shift-Period toggles showing hidden files.) This command will get rid of all instances, but will generate warning messages because many directories are not accessible:

    find / -name '.qmake.*' -delete

    If you want to limit the search, use a starting path:

    find /my/starting/path/ -name '.qmake.*' -delete

  12. Rebuild projects in QtCreator.

The technique above will presumably work for the SDKs of the other platforms (e.g. /Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs), but I haven't tried other platforms yet.

-- Thanks to https://github.com/robvanoostenrijk, who provided the key to this, and to others.

I have found a solution! It is enough to search and delete all occurrences of .qmake.stash. I failed to find them because they can also be outside the build folder! Once the .qmake.stash files have been deleted, the program compiled and run successfully.

Related