Can i import Swift Package to my Playground that is in my workspace? I've already read the answer, but i think it's outdated, because now we can use Swift Packages in iOS projects.
To open Playground on Xcode, navigate to File in the menu and click on New > Playground... To test our square function, we will choose the Blank template. Name your Playground file, then click on Create.
To use this new feature, start by opening up the Xcode 12 beta and create a new playground using the File > New > Playground command. Then, once you've picked your platform of choice and your playground has been created, convert it into an Xcode workspace by selecting File > Save As Workspace .
In Xcode 12, you can use Swift Packages with Xcode Playgrounds.
File > New > Workspace...
)File > Add Files to "Workspace Name"...
selecting the package directory.File > New > Playground...
. Ensure that you select the Workspace we just created as the "Add to" and "Group" option during Playground creation (in the assistant where you select the Playground's location on disk).You can find additional details and a sample project in this WWDC20 session: Explore Packages and Projects with Xcode Playgrounds
Ensure to check the new "Build active scheme" checkbox in the inspector for your existing Playgrounds.
Check out Arena, it allows you to create playgrounds with SPM dependencies embedded ready for use.
All it takes is
brew install finestructure/tap/arena
arena alamofire/alamofire
Update: The Swift Package Index has since gained Arena integration and you can create a playground for a package by clicking the "Try in a Playground" button on a package page.
Still now, Playground does not support the Swift Package Manager. When we try to add the Swift PM from Xcode using
File > Swift Packages > Add Package Dependency
the option is disabled.
An option is to use nef - it is an open-source project an lets you import third-party libraries in your Playgrounds. For now, it is compatible with Cocoapods but nef are working on open it for other dependency managers like Carthage and SPM.
About SPM is not an easy task, and it will be a bit different as Apple has prepared Xcode11 but I have good feelings and I think it could be ready for Sept-Oct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With