We're continuing our look at Xcode Playgrounds today with CocoaPods. Let's see what it takes to import a CocoaPod into a Playground.
We'll begin by creating a new Xcode Project. Next, we'll head into our project's directory and run
pod init to generate our
Podfile. We'll open it up and configure it just as we usually would:
platform :ios, '9.0' use_frameworks! link_with 'Spaceships' pod 'Alamofire'
Then we'll run
pod install to generate the Workspace file for our project and install our pods. We're almost done, next we need create a new Playground and add it to our project.
Finally, we need to add our Playground to our Podfile's
link_with directive (only its name, not the .playground extension):
link_with 'Spaceships', 'scratch-pad'
pod install one more time and we're done. We can now import the pod we installed into our Playground and try it out. Neat!