Package platforms not working

I am writing a package in Swift using Xcode 16.1 (swift-tools-version: 6.0) and am trying to use features that became available in later versions of macOS and iOS.

The following line naturally causes a compiler error when compiling against 'My Mac':

let match = "test-string".firstMatch(of: /-(.+)/)!

'firstMatch(of:)' is only available in macOS 13.0 or newer

I can of course fix this by using @available(macOS 13.0, *), but there are dozens of methods and I would prefer to use the platforms property in the Package file like this:

	platforms: [
		.macOS(.v10_13),
		.iOS(.v16)
	],

However for reason that are not clear, this does not work and the compiler errors remain.

I have tried cleaning, removing derived data etc.

What I am doing wrong?

Answered by DTS Engineer in 818561022

Your platform declaration shows you are choosing macOS 10.13, which is not the same as macOS 13.0. That's easy to miss! Does your code still not compile after you correct that?

— Ed Ford,  DTS Engineer

Accepted Answer

Your platform declaration shows you are choosing macOS 10.13, which is not the same as macOS 13.0. That's easy to miss! Does your code still not compile after you correct that?

— Ed Ford,  DTS Engineer

Doh! That's fixed it - Thanks Ed

Package platforms not working
 
 
Q