使用 cocoapods 时如何将项目代码公开到 Xcode 游乐场?
How to expose your project code to a Xcode playground when using cocoapods?
在像 https://useyourloaf.com/blog/adding-playgrounds-to-xcode-projects/, or the kickstarter source code http://github.com/kickstarter/ios-oss 这样的博文中,他们将 playground 添加到 xcode 项目中,以便对应用程序中的不同视图控制器和视图组件进行文档和可视化测试。
他们推荐的典型方法如下:
- 创建一个新的框架目标
- 将您的代码添加到框架目标(具有正确的访问级别)
- 将 playground 文件添加到工作区
- 构建你的框架
- 然后该框架将在 playground 中可用。
这在不使用 cocoapods 的情况下有效,但我发现当您 do 使用 cocoapods.[=12= 时情况并非如此]
将 playground 添加到 Xcode 工作区后,Pods 在 playground 中可用,但不是我的自定义框架。
我不明白 cocoapods 如何使 pods 在 playground 中可用
我不明白 playground 内部如何决定哪些框架可用于导入等。
你们有没有做到这一点?有指导吗?
谢谢
这是可行的。在您的 Podfile
中,您需要为您的应用程序和您的框架声明目标,以便 CocoaPods 可以向两者添加 pods。这是一个例子。可以查看教程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'
在 XCode 13.2 中,这要容易得多。
打开您的应用项目,转到“文件”>“新建”>“游乐场”。
在保存 window 中,转到显示“添加到:”的下拉列表,将“不要添加到任何项目或工作区”替换为您的项目(见下文)。点击创建。
在应用项目中打开 playground 文件window
从您的应用中导入任何 pod/target 或在 playground
中使用任何 class
点击 Playground 中的 Run/Play 图标,这将首先构建您的整个项目,然后在最后 运行 您的 playground 代码。
在像 https://useyourloaf.com/blog/adding-playgrounds-to-xcode-projects/, or the kickstarter source code http://github.com/kickstarter/ios-oss 这样的博文中,他们将 playground 添加到 xcode 项目中,以便对应用程序中的不同视图控制器和视图组件进行文档和可视化测试。
他们推荐的典型方法如下:
- 创建一个新的框架目标
- 将您的代码添加到框架目标(具有正确的访问级别)
- 将 playground 文件添加到工作区
- 构建你的框架
- 然后该框架将在 playground 中可用。
这在不使用 cocoapods 的情况下有效,但我发现当您 do 使用 cocoapods.[=12= 时情况并非如此]
将 playground 添加到 Xcode 工作区后,Pods 在 playground 中可用,但不是我的自定义框架。
我不明白 cocoapods 如何使 pods 在 playground 中可用
我不明白 playground 内部如何决定哪些框架可用于导入等。
你们有没有做到这一点?有指导吗?
谢谢
这是可行的。在您的 Podfile
中,您需要为您的应用程序和您的框架声明目标,以便 CocoaPods 可以向两者添加 pods。这是一个例子。可以查看教程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'
在 XCode 13.2 中,这要容易得多。
打开您的应用项目,转到“文件”>“新建”>“游乐场”。
在保存 window 中,转到显示“添加到:”的下拉列表,将“不要添加到任何项目或工作区”替换为您的项目(见下文)。点击创建。
在应用项目中打开 playground 文件window
从您的应用中导入任何 pod/target 或在 playground
中使用任何 class点击 Playground 中的 Run/Play 图标,这将首先构建您的整个项目,然后在最后 运行 您的 playground 代码。