I've created a sample project illustrating my issue here.
In summary, I'm trying to use a "vendored framework" CocoaPod inside a workspace playground. I think this is possible but requires a bit of fiddling with project settings, and I can't quite figure out what to change.
To observe the issue in the sample project, do the following:
- Open
CocoaPods-Test/CocoaPods-Test.xcworkspacein Xcode. - Pods should be installed and committed in the repository, but can run
pod installif necessary. - Note that the
CocoaPods-Testtarget builds and runs successfully, importingPromiseKitandTwilioChatClientpods. - Navigate to
Playground.playgroundwithin the workspace. - Note that the playground executes fine while importing
PromiseKitbut ifTwilioChatClientis imported, playground execution fails with "no such module 'TwilioChatClient'".
After reading the following resources:
- 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/
I think the issue is probably related to the fact that TwilioChatClient is a "vendored framework" (see its podspec), which means a pod target is not created for it. After reading the above resources, I feel like a solution is within reach, but I can't quite figure it out.
While the sample project here illustrates what I think is the underlying issue, the issue that prompted me to create this example project is just a small bit more complicated.
In my project, I create a framework target containing all my app's code (so it can be imported into my app and also into my playgrounds using app resources). This framework then has pod dependencies, including PromiseKit and TwilioChatClient. The execution error in the playground is different ("Couldn't lookup symbols" instead of "no such module"), as I am not importing the CocoaPods module directly but my framework which uses the pod framework.
I suspect if I can solve the "no such module" issue, it will help me solve my "couldn't lookup symbols" issue.
Finally, this seems like a good opportunity to make an open source contribution others don't seem to have wanted to do (see discussion 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). Any references to help understand the Xcode build process and what CocoaPods is doing under the hood are appreciated. It seems like the resources I've found are either "a very high level overview" (which I get), or "digging through the source code", with not a whole lot in between.