In blog posts like https://useyourloaf.com/blog/adding-playgrounds-to-xcode-projects/, or the kickstarter source code http://github.com/kickstarter/ios-oss they add playground to xcode projects in order to have documentation + visual tests of the different view controllers and view components in the app.
The typical way they recommend to do it is like:
This works without using cocoapods, but i have found that it's not the case when you do use cocoapods.
After adding a playground to the Xcode workspace, the Pods are available in the playground, but not my custom framework.
I don't understand how cocoapods work to make the pods available in the playground
I don't understand how internally playground decides which frameworks to have available for import, etc.
Does any of you have achieved this? have pointers to do it?
Thanks
In the Swift Playgrounds app on your Mac, click Run My Code (or use the Touch Bar). If there are instructions on the right side of the screen, they slide down when you click Run My Code, so you can watch your code run in the live view. When you click Stop, the instructions slide back up.
It is doable. In your Podfile
, you need to declare targets for both your app and your framework, so that CocoaPods can add pods to both. Here is an example. You can check the tutorial Using Playground, demo and Medium post https://medium.com/flawless-app-stories/playground-driven-development-in-swift-cf167489fe7b
platform :ios, '9.0'
use_frameworks!
pod 'Cheers'
target 'UsingPlayground'
target 'AppFramework'
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