Unable to build swift main toolchain locally after installing Xcode 26?

I just attempted to build a swift main toolchain locally after installing Xcode 26. I set my command line tools to Xcode 26. I then open a terminal window and attempt to build a main toolchain and see some weird errors that seem to point back to Foundation.

The errors seem related to "macOS 16" checks that maybe should be coded as "macOS 26" checks?

/Applications/Xcode_26_beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/Library/Frameworks/Foundation.framework/Modules/Foundation.swiftmodule/arm64e-apple-macos.swiftinterface:16364:13: error: '_distance(from:to:)' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
16359 | extension Swift.Set : Swift.CVarArg {
16360 | }
16361 | extension Foundation.AttributedString.Runs {
      | `- note: add '@available' attribute to enclosing extension
16362 |   @_alwaysEmitIntoClient public func distance(from start: Foundation.AttributedString.Runs.Index, to end: Foundation.AttributedString.Runs.Index) -> Swift.Int {
      |                                      `- note: add '@available' attribute to enclosing instance method
16363 |         if #available(macOS 16, iOS 19, tvOS 19, watchOS 12, visionOS 3, *) {
16364 |             _distance(from: start, to: end)
      |             |- error: '_distance(from:to:)' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
      |             `- note: add 'if #available' version check
16365 |         } else {
16366 |             start.distance(to: end)

/Applications/Xcode_26_beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/Library/Frameworks/Foundation.framework/Modules/Foundation.swiftmodule/arm64e-apple-macos.swiftinterface:19693:18: error: '_setActionNameLocalizedStringResource' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
19682 |   }
19683 | }
19684 | extension Foundation.UndoManager {
      | `- note: add '@available' attribute to enclosing extension
19685 |   @available(macOS 10.11, iOS 9.0, watchOS 2.0, tvOS 9.0, *)
19686 |   @preconcurrency @_Concurrency.MainActor public func registerUndo<TargetType>(withTarget target: TargetType, handler: @escaping @_Concurrency.MainActor (TargetType) -> Swift.Void) where TargetType : AnyObject
      :
19691 |         if #available(macOS 16, iOS 19, tvOS 19, watchOS 12, visionOS 3, *) {
19692 |              
19693 |             self._setActionNameLocalizedStringResource(actionNameResource)
      |                  |- error: '_setActionNameLocalizedStringResource' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
      |                  `- note: add 'if #available' version check
19694 |         } else {
19695 |             let actionName: String

/Applications/Xcode_26_beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/Library/Frameworks/Foundation.framework/Modules/Foundation.swiftmodule/arm64e-apple-macos.swiftinterface:21692:18: error: 'init(__dsoHandle:)' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
21685 |   #endif
21686 | }
21687 | extension Foundation.Bundle {
      | `- note: add '@available' attribute to enclosing extension
21688 |   #if compiler(>=5.3) && $NonescapableTypes
21689 |   @available(macOS 12, iOS 15, tvOS 15, watchOS 8, visionOS 1, *)
21690 |   @_alwaysEmitIntoClient convenience public init?(_dsoHandle: Swift.UnsafeRawPointer) {
21691 |         if #available(macOS 16, iOS 19, tvOS 19, watchOS 9, visionOS 3, *) {
21692 |             self.init(__dsoHandle: _dsoHandle)
      |                  |- error: 'init(__dsoHandle:)' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
      |                  `- note: add 'if #available' version check
21693 |             return
21694 |         }

/Applications/Xcode_26_beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk/System/Library/Frameworks/Foundation.framework/Modules/Foundation.swiftmodule/arm64e-apple-macos.swiftinterface:21692:18: error: 'init(__dsoHandle:)' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
21685 |   #endif
21686 | }
21687 | extension Foundation.Bundle {
      | `- note: add '@available' attribute to enclosing extension
21688 |   #if compiler(>=5.3) && $NonescapableTypes
21689 |   @available(macOS 12, iOS 15, tvOS 15, watchOS 8, visionOS 1, *)
21690 |   @_alwaysEmitIntoClient convenience public init?(_dsoHandle: Swift.UnsafeRawPointer) {
21691 |         if #available(macOS 16, iOS 19, tvOS 19, watchOS 9, visionOS 3, *) {
21692 |             self.init(__dsoHandle: _dsoHandle)
      |                  |- error: 'init(__dsoHandle:)' is only available in macOS 26.0 or newer; clients of 'Foundation' may have a lower deployment target
      |                  `- note: add 'if #available' version check
21693 |             return
21694 |         }

I wasn't able to find any open tasks or diffs on swift-foundation that look related to that… any ideas?

1 Like

This is being tracked with a fix in the compiler here and here.

3 Likes

ahh… thanks! i'm guessing the legit workaround for now before that lands is to set my command line tools to xcode 16.4 before building swift main locally?

I think that should work.

1 Like

The changes to support this are now merged to main and the 6.2 branch.

1 Like