Xcode: "invalid Darwin version number"

With both Xcode 12.4 (from the App Store) and with Xcode 12.5 beta 2 (only installed after having those problems with Xcode 12.4) I get the following errors when trying to build a project (newly created simple "Hello World" project) under Big Sur 11.2.2 (Intel):

<unknown>:0: error: invalid Darwin version number: macos11.2
<unknown>:0: error: invalid version number in '--target=x86_64-apple-macos11.2'
<unknown>:0: error: invalid Darwin version number: macos11.3
<unknown>:0: error: invalid version number in '--target=x86_64-apple-macos11.3'
<unknown>:0: error: failed to load module 'Combine'
<unknown>:0: error: invalid Darwin version number: macos11.3
<unknown>:0: error: invalid version number in '--target=x86_64-apple-macos11.3'

(Before installing Xcode 12.5 beta 2 the error was "invalid Darwin version number: macos11.1 ...".)

Note: I am not including "Combine".

I searched for solutions in the internet but nothing I found helped. Right now I am not able to build Swift projects (at least not in Xcode). What can I do to fix this?

Additional question: How can I ensure that the swiftc versions for Xcode and in the command line (terminal) are the same? They seemed to differ.

...I had to remove an old Swift toolchains via Xcode preferences / Components. Now I can compile again. But it is not really understandable if you are not familiar with those issues. Some better tooling would be great here (also for my second question about swiftc in Xcode and in the command line).

When a different toolchain is selected, Xcode's activity view will contain a :link: symbol.

Perhaps this indicator should be more prominent, such as by changing Xcode's app icon in the dock?

Xcode's preferences window has a Locations tab, where you can select which version of Xcode provides the command line tools.

You can also override this default selection, by setting an environment variable in your command.

  • e.g. DEVELOPER_DIR="/Applications/Xcode-beta.app" (from man xcode-select).
  • e.g. TOOLCHAINS=swift (from the Getting Started page).
1 Like
Terms of Service

Privacy Policy

Cookie Policy