Pods in Playgrounds

I had a random thought while driving - wouldn’t it be fun to play with some new CocoaPods in Playgrounds? It occurred to me that this wasn’t something I had just stumbled across in my normal blog surfing. It turns out to be fairly easy, but the “obvious” answer from StackOverflow doesn’t work if you have updated to the 1.0 version of CocoaPods.

Check out this github project. You don’t even need to clone the repository, just look at the steps in the Readme:

• Create a new Xcode project
• Close Xcode
• Navigate to project directory
• pod init
• Update Podfile with Alamofire (see example)
• pod install
• Open .xcworkspace
• Add a new playground to the workspace
• Manage schemes -> Check 'Alamofire'
• Build the Alamofire scheme
• Xcode triggers a warning about updating the bundle settings for Alamofire; accept changes
• You should now be able to 'import Alamofire' in the playground


Replace Alamofire with your desired pod, and voila. The trick here seems to be building the scheme associated with the Pod. I tried to add two Pods, and didn’t have any luck - I suspect whatever Xcode is doing when it “fixes” your bundle settings is only valid for the first pod, not both. However, if you want to test out a single pod (Obj-C or Swift), this seems to be a fairly straightforward way of doing it.

I’m hoping this blog post servers as a reminder to myself as well as a help to anyone who is struggling with this in CocoaPods 1.0! I was using Xcode 7.3.1 and CocoaPods 1.0.1.


© 2010-2016 Little Potato Software   Follow littlepotatosw on Twitter        Site Map     Privacy Policy     Contact Me