swiftly icon indicating copy to clipboard operation
swiftly copied to clipboard

Detect mismatched toolchain and macOS SDK

Open cmcgee1024 opened this issue 2 months ago • 1 comments

Lately, the macOS CI was failing for swiftly with mysterious compiler errors.

It was caused by the builders being upgrade to a newer macOS (Tahoe), and a new macOS SDK. Swift toolchains for macOS can’t work with newer macOS SDK version. The fix was to bump the swift version that we use for building and testing swiftly, but the compile errors didn’t make this very clear.

Since system dependency management is being considered for Linux, this might be another aspect of that. Swiftly can detect misalignments in the following way on macOS:

  • Use xcrun --show-sdk-path to find the current macOS SDK path
  • From that path find a stable .swiftinterface file, such as System/Library/Frameworks/Foundation.framework/Versions/C/Modules/Foundation.swiftmodule/arm64e-apple-ios-macabi.swiftinterface
  • Check the first few lines in the file for a header that has swift-compiler-version
  • Determine if any installed toolchains, especially the one that is in-use is older than this version

cmcgee1024 avatar Oct 03 '25 16:10 cmcgee1024

Would this be something like adding an additional command like swiftly diagnose that checks for the given route for version mismatch?

louisunlimited avatar Oct 07 '25 06:10 louisunlimited