Cake icon indicating copy to clipboard operation
Cake copied to clipboard

Is there a way to use cake and Cocoapods at the same time?

Open abbasmousavi opened this issue 5 years ago • 11 comments

Is there a way to use cake and Cocoapods at the same time? This way we can use Cocoapods for dependencies like 3rd party libraries and use Cake to modularize our code.

abbasmousavi avatar Mar 06 '19 15:03 abbasmousavi

Yes, but the Batter (currently) cannot use CocoaPods since it cannot see the Pod libraries.

We can probably make this automatic, if we detect the Pods directory we could its Pods target as a dependency of the Batter.

Longer term I’d like the Cakefile to be able to specify pods as dependencies.

mxcl avatar Mar 06 '19 15:03 mxcl

@mxcl The scenario in my mind is to use cocoapods for 3rd party libraries and Cake to modularize my code. So for start, it is enough if the project builds with Cocoapods and Cake at the same time.

I can start work on this, can you guide me where to look in the code?

abbasmousavi avatar Mar 06 '19 21:03 abbasmousavi

The XcakeProject module is where we generate the Cake.xcodeproj, in there we will need to detect if the prefix is a Pods project, depend on the external target in the Pods xcodeproj and (maybe) add some link/include paths.

mxcl avatar Mar 06 '19 21:03 mxcl

The scenario in my mind is to use cocoapods for 3rd party libraries and Cake to modularize my code. So for start, it is enough if the project builds with Cocoapods and Cake at the same time.

Yeah, so your modules (the Batter) will need that the Pods build first (the target dependency) and that they can see the Pods (so add search paths). Then it should work.

mxcl avatar Mar 06 '19 21:03 mxcl

@mxcl I have a sample project here: https://github.com/abbasmousavi/CakePods It has some pods and is integrated with Cake and it builds successfully.

I am trying to add required dependency and search paths manually, in order to understand what should be added to it to work.

I have tried adding Pod.framework as a dependency to Batter and adding search paths to it, but it does not work. also, we need to have access to pods from all modules inside Batter, so maybe we should add dependency and search paths to all modules in Batter? Would you please take a look at this? what should be added to this project in order to have access from inside Bar module to Alamofire?

abbasmousavi avatar Mar 07 '19 01:03 abbasmousavi

we need to have access to pods from all modules inside Batter, so maybe we should add dependency and search paths to all modules in Batter?

Yes, all batter modules will need this. We have a loop or two already in there for Batter modules, so you can add the dependency there.

I have tried adding Pod.framework as a dependency to Batter and adding search paths to it, but it does not work.

What's the error?

Would you please take a look at this? what should be added to this project in order to have access from inside Bar module to Alamofire?

K, so you mean the link you provided?

mxcl avatar Mar 07 '19 01:03 mxcl

This works: https://github.com/mxcl/CakePods

I had to:

  • Add the Pods project to the Cake project
  • Add the Pod xcconfig files to the Cake project
  • Make the project settings use the xcconfig files
  • Make all Batter targets depend on CakePods-Pods

mxcl avatar Mar 07 '19 03:03 mxcl

Note when opening it don’t have Cake.app running or it will regenerate Cake.xcodeproj and the changes will be lost.

mxcl avatar Mar 07 '19 14:03 mxcl

Sorry for the delay, thank you for fixing the project, now it builds. I am trying to implement the steps that you have done on the project in the code.

abbasmousavi avatar Mar 08 '19 13:03 abbasmousavi

LMK if I can help, I found figuring out how to make xcodeprojs quite tricky.

We use tuist/xcodeproj, but I made a facade wrapper (module: XcodeProject) that should be capable of all the above (I believe).

mxcl avatar Mar 08 '19 14:03 mxcl

@mxcl please take a look at https://github.com/mxcl/Cake/pull/52. I am not familiar with tuist/xcodeproj, I have tried to follow the patterns in the code and I have tested the result on a simple cocoapods project and it worked. please let me know if it needs anything to be added or changed.

abbasmousavi avatar Mar 10 '19 01:03 abbasmousavi