Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Use "Vendored Framework" CocoaPod Inside Workspace Playground

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.xcworkspace in Xcode.
  • Pods should be installed and committed in the repository, but can run pod install if necessary.
  • Note that the CocoaPods-Test target builds and runs successfully, importing PromiseKit and TwilioChatClient pods.
  • Navigate to Playground.playground within the workspace.
  • Note that the playground executes fine while importing PromiseKit but if TwilioChatClient is 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.

like image 973
Tim Arnold Avatar asked May 23 '17 15:05

Tim Arnold


1 Answers

If you must have this work, I came up with a workaround by creating a framework target inside the Pods project which is named the same as the vendor framework, and uses all its headers publicly, using the framework as a sole dependency. I have forked your GH example and linked it here. enter image description here enter image description here

It's not the most elegant solution, but it will help you out in a pinch.

UPDATE Build "fake" framework first, then build app target, then go to playground.

like image 80
diatrevolo Avatar answered Nov 15 '22 19:11

diatrevolo