My project created with:
swift package init --type tool --name MyProject
print("\(Date.now)") // 'now' is only available in macOS 12 or newer
How to set macOS target version to 14.0?
When you're using Swift on the command line, it's always (currently) targeting the OS that you're own. Swift only recently started including the capabilities for cross compilation (you can read up the details of the evolution proposal that's been accepted to support this: https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md), which is probably the best documentation on what's to come - but that doesn't help you currently.
In the meantime, if you want to target macOS 14.0 explicitly for a swift package, open the Package.swift in Xcode - it'll allow you to select a specific target and build for that target.
I don't see anyway to set any of this in Xcode. Clicking on the top entry on Project Navigator opens
So specifying the
platforms arg in
Sounds good, glad that is working for you!
Nothing wrong with how you pinned it, but worth being aware that platforms stanza in package.swift is specifying the minimum platform that your code should be pinned to (SupportedPlatform | Apple Developer Documentation). in your example, your package wouldn't compile on macOS 12 or 13. If that fits your needs, run with it!