How does one specify a minimum target of iOS(.v17) in a swift package

Looking for something like this.

let package = Package( name: "Core", defaultLocalization: "en", platforms: [ .iOS(.v16) ],

Also, I assume since my package is still using v16, I will not see new types like @Observable. Is that a valid assumption as to why I don't see these new types?

Accepted Reply

Disregard, that's minimum target.

Replies

Disregard, that's minimum target.

Hey @cyclic. Did you solve your issue? Unfortunately, when I try to use @Observable in a Swift Package I get the following error: "'ObservationRegistrar' is only available in iOS 17.0 or newer".

You?

For all those struggling with this, I found the fix. Make sure Swift Tools Version is 5.9 at the top of your package.swift file:

// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

Then you're allowed to specify iOS 17 in your platforms declaration:

platforms: [.iOS(.v17)],