To test my suspicion that this is an Xcode issue and not macOS 15 issue, I used Swift Package Manager to built a small executable instead of building it with Xcode. The complete software (using the new Span API) is this:
import Foundation
@main
struct App {
static func main() {
let data = Data([1, 2, 3, 4, 5])
let span = data.span
print(span[2])
}
}
using this Package.swift file
// swift-tools-version: 6.2
import PackageDescription
let package = Package(
name: "span-compat-test",
platforms: [.macOS(.v13)],
targets: [.executableTarget(name: "span-compat-test")]
)
I make an executable by running swift build -c release on macOS 26 using Apple Swift version 6.2.1 (swift-6.2.1-RELEASE).
The resulting executable runs on macOS 26, macOS 15, and macOS 14. I have not tested older OS versions.
So, SwiftPM is able to compile the executable in a way that runs on older OS versions while in Xcode I currently require a manual workaround.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: