Closed ffried closed 1 month ago
I am able to reproduce. Not sure yet where the 5.0 comes from, this looks correct: https://github.com/apple/swift-package-manager/blob/main/Sources/PackageModel/Platform.swift#L44C5-L44C99
@neonichu thanks for confirming. Is there a way to build for watchOS using SPM alone (not using Xcode)? I've skimmed through the SPM source code as well and was unable to spot an obvious mistake Which is why I first hesitated to create an issue here. It could also be Xcode's fault, right?
Yah, it doesn't seem to reproduce when doing that, so it's somewhat likely that the issue lies in Xcode, but it's not 100% clear to me.
What you can do is:
❯ cat destination.json
{
"version": 1,
"sdk": "/Applications/Best.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS11.0.sdk",
"toolchain-bin-dir": "/Applications/Best.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin",
"target": "arm64-apple-watchos4.0",
"extra-cc-flags": [],
"extra-cpp-flags": [],
"extra-swiftc-flags": [],
}
❯ swift build --destination destination.json
For the record, I've just filed this as a feedback as well: FB13239890
This technically behaves correctly. The iOS minimum version is 12, which maps to watchOS 5. So in the absence of any explicitly specified versions, SwiftPM defaults to iOS 12, which in turn defaults to watchOS 5.
The watchOS minimum version happens to be 4, but because of iOS's higher minimum, it defaults to 5.
@jakepetroules Thanks for the explanation! And sorry for the late reply - totally went under the radar on my side.
I'm a bit torn between seeing the link between iOS and watchOS on the one hand, but still wondering whether this actually makes sense on the other hand. If I created a watchOS only package (w/o currently being able to specify this in the Package manifest), I'd probably expect the default version to be the minimum - just like it would be for e.g. macOS or iOS.
Either way, I'll close this as "Won't fix".
Description
A package (e.g.
pkg1
) that does not define anyplatforms
seems to be using watchOS 5 instead of 4. If another package (e.g.pkg2
) depends on that package, but explicitly defines watchOS 4 as minimum supported version, it will fail to build.Using Xcode 15 / Swift 5.9, the minimum supported watchOS version is 4 (according to the release notes):
Expected behavior
The second package builds fine.
Actual behavior
The build fails with the following error:
Steps to reproduce
pkg1
with a target and productPackage1
but no platforms specified.pkg2
with a targetPackage2
.platforms
ofpkg2
to[.watchOS(.v4)]
.pkg1
as dependency ofpkg2
, as well as the productPackage1
as a dependency of targetPackage2
.Swift Package Manager version/commit hash
Whatever is bundled with Swift 5.9 in Xcode 15.0
Swift & OS version (output of
swift --version ; uname -a
)