无法在 Workspace Playground 中使用 "Vendored Framework" CocoaPod
Can't Use "Vendored Framework" CocoaPod Inside Workspace Playground
我创建了一个示例项目来说明我的问题 here。
总而言之,我正在尝试在工作区操场内使用 "vendored framework" CocoaPod。我认为这是可能的,但需要对项目设置进行一些调整,而且我不太清楚要更改什么。
要观察 sample project 中的问题,请执行以下操作:
- 在 Xcode 中打开
CocoaPods-Test/CocoaPods-Test.xcworkspace
。
- Pods 应安装并提交到存储库中,但如有必要,可以 运行
pod install
。
- 请注意,
CocoaPods-Test
目标已成功构建并 运行s,导入 PromiseKit
和 TwilioChatClient
pods。
- 导航到工作区内的
Playground.playground
。
- 请注意,playground 在导入
PromiseKit
时执行良好,但如果导入 TwilioChatClient
,playground 执行失败并显示 "no such module 'TwilioChatClient'"。
阅读以下资源后:
- https://github.com/CocoaPods/CocoaPods/issues/5334
- https://github.com/CocoaPods/CocoaPods/issues/5215
- https://github.com/CocoaPods/CocoaPods/issues/5563
- https://github.com/CocoaPods/swift/issues/3
- https://github.com/CocoaPods/CocoaPods/issues/4135
- https://github.com/CocoaPods/CocoaPods/issues/2240
- https://github.com/CocoaPods/CocoaPods/issues/6669#issuecomment-300188519
- https://guides.cocoapods.org/using/troubleshooting.html
- https://www.objc.io/issues/6-build-tools/cocoapods-under-the-hood/
我认为这个问题可能与 TwilioChatClient
是一个 "vendored framework"(参见它的 podspec)这一事实有关,这意味着没有为它创建 pod 目标。看了上面的资源,感觉指日可待,但又想不通。
虽然此处的示例项目说明了我认为的根本问题,但促使我创建此示例项目的问题稍微复杂一些。
在我的项目中,我创建了一个包含我所有应用程序代码的框架目标(因此它可以导入我的应用程序,也可以使用应用程序资源导入我的游乐场)。这个框架然后有 pod 依赖,包括 PromiseKit
和 TwilioChatClient
。 playground 中的执行错误是不同的("Couldn't lookup symbols" 而不是 "no such module"),因为我不是直接导入 CocoaPods 模块而是我的框架使用 pod 框架。
我怀疑如果我能解决 "no such module" 问题,它会帮助我解决我的 "couldn't lookup symbols" 问题。
最后,这似乎是做出其他人似乎不想做的开源贡献的好机会(参见讨论 here). Tangentially, I'd love to contribute but just don't feel like I understand what exactly is going on with CocoaPods, the Xcode build process, etc., after reading about it a bit (e.g. here and here)。任何有助于理解 Xcode 构建过程以及 CocoaPods 在幕后所做的事情的参考资料都值得赞赏。我找到的资源似乎是 "a very high level overview"(我得到的)或 "digging through the source code",两者之间的资源不多。
如果您必须完成这项工作,我想出了一个解决方法,即在 Pods 项目中创建一个与供应商框架同名的框架目标,并使用其所有 headers公开地,使用框架作为唯一的依赖。我已经分叉了你的 GH 示例并将其链接 here。
这不是最优雅的解决方案,但它会在紧要关头帮助您。
更新
先构建 "fake" 框架,然后构建应用程序目标,然后去游乐场。
我创建了一个示例项目来说明我的问题 here。
总而言之,我正在尝试在工作区操场内使用 "vendored framework" CocoaPod。我认为这是可能的,但需要对项目设置进行一些调整,而且我不太清楚要更改什么。
要观察 sample project 中的问题,请执行以下操作:
- 在 Xcode 中打开
CocoaPods-Test/CocoaPods-Test.xcworkspace
。 - Pods 应安装并提交到存储库中,但如有必要,可以 运行
pod install
。 - 请注意,
CocoaPods-Test
目标已成功构建并 运行s,导入PromiseKit
和TwilioChatClient
pods。 - 导航到工作区内的
Playground.playground
。 - 请注意,playground 在导入
PromiseKit
时执行良好,但如果导入TwilioChatClient
,playground 执行失败并显示 "no such module 'TwilioChatClient'"。
阅读以下资源后:
- https://github.com/CocoaPods/CocoaPods/issues/5334
- https://github.com/CocoaPods/CocoaPods/issues/5215
- https://github.com/CocoaPods/CocoaPods/issues/5563
- https://github.com/CocoaPods/swift/issues/3
- https://github.com/CocoaPods/CocoaPods/issues/4135
- https://github.com/CocoaPods/CocoaPods/issues/2240
- https://github.com/CocoaPods/CocoaPods/issues/6669#issuecomment-300188519
- https://guides.cocoapods.org/using/troubleshooting.html
- https://www.objc.io/issues/6-build-tools/cocoapods-under-the-hood/
我认为这个问题可能与 TwilioChatClient
是一个 "vendored framework"(参见它的 podspec)这一事实有关,这意味着没有为它创建 pod 目标。看了上面的资源,感觉指日可待,但又想不通。
虽然此处的示例项目说明了我认为的根本问题,但促使我创建此示例项目的问题稍微复杂一些。
在我的项目中,我创建了一个包含我所有应用程序代码的框架目标(因此它可以导入我的应用程序,也可以使用应用程序资源导入我的游乐场)。这个框架然后有 pod 依赖,包括 PromiseKit
和 TwilioChatClient
。 playground 中的执行错误是不同的("Couldn't lookup symbols" 而不是 "no such module"),因为我不是直接导入 CocoaPods 模块而是我的框架使用 pod 框架。
我怀疑如果我能解决 "no such module" 问题,它会帮助我解决我的 "couldn't lookup symbols" 问题。
最后,这似乎是做出其他人似乎不想做的开源贡献的好机会(参见讨论 here). Tangentially, I'd love to contribute but just don't feel like I understand what exactly is going on with CocoaPods, the Xcode build process, etc., after reading about it a bit (e.g. here and here)。任何有助于理解 Xcode 构建过程以及 CocoaPods 在幕后所做的事情的参考资料都值得赞赏。我找到的资源似乎是 "a very high level overview"(我得到的)或 "digging through the source code",两者之间的资源不多。
如果您必须完成这项工作,我想出了一个解决方法,即在 Pods 项目中创建一个与供应商框架同名的框架目标,并使用其所有 headers公开地,使用框架作为唯一的依赖。我已经分叉了你的 GH 示例并将其链接 here。
这不是最优雅的解决方案,但它会在紧要关头帮助您。
更新 先构建 "fake" 框架,然后构建应用程序目标,然后去游乐场。