I’m curious, am I wrong in hoping that the platforms
option in the Package
file of a swift macro package should set the target os for the contents of that package?
When creating a default (Multiplatform > Swift) macro package with Xcode (15.4), I end up with a Package
file that starts like this:
let package = Package(
name: "MyMacroPackage",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .macCatalyst(.v13)],
products: [...
It also creates a main.swift
file in the MyMacroPackageClient
folder that can be used to test my macros. If I add the following to main.swift
:
@Model
struct MyRecord {
var name: String = ""
init(name: String) {
self.name = name
}
}
I get the error 'Model()' is only available in macOS 14 or newer
.
But the platforms
option in the Package manifest is specifying macOS 15 and onward. Why is Xcode giving me this error? I know I can solve this by adding something like @available(macOS 15, *)
before the declaration for MyRecord
, but it seems redundant, considering the platforms
configuration. What am I missing? Is there some other option in the Package
file that I need to configure?