Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set deployment target for a Xcode playground

I've upgraded to MacOS 11 (Big Sur) Beta 4. And Xcode 12 beta 4.

I have a Swift playground with Combine publishers:

Just([1,2,3])
    .setFailureType(to: Error.self) // Make the compiler pick up new API in MacOS Big Sur
    .flatMap { $0.publisher }
    .sink(receiveCompletion: { print($0) }, receiveValue: { print($0) })

After upgrading my playgrounds start to fail with the message: "'flatMap(maxPublishers:_:)' is only available in macOS 11.0 or newer". The swift compiler dosen't indicate any errors in the code. And the code works fine if placed in a normal Xcode command line app project.

The error can be mitigated by enclosing the publisher in a availability check like, if #available(macOS 11.0, *) { } in the playground.

I'm assuming this is a bug and I've filed an issue with Apple.

Or is this expected behavior? And if it is ... is there a way to hint to a playground what deployment target to assume? If it's not correctly picking up the actual version of the operating system it's running against.

Thanks!

like image 948
weenzeel Avatar asked Sep 14 '25 02:09

weenzeel


1 Answers

Yes there is, but a bit hidden...

Open your 'MyName.swiftpm' package by right clicking it in Finder and select 'Show Package Contents'. Then you should see a 'Package.swift' file.

Open it with a simple text editor and change the 'platforms' entry (e.g. to iOS 17):

    platforms: [
    .iOS("17.0")
]
like image 65
LaborEtArs Avatar answered Sep 15 '25 15:09

LaborEtArs