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.
在https://useyourloaf.com/blog/adding-playgrounds-to-xcode-projects/等博客文章或kickstarter源代码http://github.com/kickstarter/ios-oss中,他们将操场添加到xcode项目中为了获得应用程序中不同视图控制器和视图组件的文档+可视化测试。
The typical way they recommend to do it is like:
他们建议的典型方式是:
- Create a new framework target
- Add your code to the framework target (with the right access levels)
- Add a playground file to the workspace
- Build your framework
- Then the framework will be available within the playground.
创建一个新的框架目标
将您的代码添加到框架目标(具有正确的访问级别)
将playground文件添加到工作区
构建您的框架
然后框架将在操场内提供。
This works without using cocoapods, but i have found that it's not the case when you do use cocoapods.
这可以不使用cocoapods,但我发现当你使用cocoapods时并非如此。
After adding a playground to the Xcode workspace, the Pods are available in the playground, but not my custom framework.
将操场添加到Xcode工作区后,Pod可以在操场上使用,但不能在我的自定义框架中使用。
I don't understand how cocoapods work to make the pods available in the playground
我不明白cocoapods如何在操场上制作豆荚
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
1 个解决方案
#1
6
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
这是可行的。在您的Podfile中,您需要为应用程序和框架声明目标,以便CocoaPods可以向两者添加pod。这是一个例子。你可以查看教程使用Playground,demo和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'
#1
6
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
这是可行的。在您的Podfile中,您需要为应用程序和框架声明目标,以便CocoaPods可以向两者添加pod。这是一个例子。你可以查看教程使用Playground,demo和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'