Srinath Shah
Srinath Shah

Reputation: 21

How can you use cocoapod framework into another cocoapod created locally?

Specifically:

  1. Created a new project
  2. Setup CocoaPods

  3. To the Pod file under Pods I added a dependency (for ex.AlamoFire)

  4. The main app which consumes the pods can import Alamofire
  5. The local cocoapod which I created and added by using the following lines in the podfile:

    target 'SomeValue' do my_own_pod pod 'CocoaPod_2', :path => '/LocalPath/To/PodSource' end

  6. Ran pod install and I added the AlamoFire Framework to the CocoaPod_2 under Pods -> General-> CocoaPod_2-> Linked Libraries & Binaries

  7. At this point I was expecting that importing Alamofire in my CocoaPod_2 will work fine but its not.

Screenshot of the workspace :

MyProject.XCWorkspace |_MyProject.App |____Source Code files importing CocoaPod_1 (Embedded using CocoaPod) |____Source Code files importing CocoaPod_2 (Embedded using CocoaPods, local Pod) |_Pods |____Podfile |____Frameworks |____Pods |___CocoaPod_1 |___CocoaPod_1 Source Files |____Source Code for Local Pod |___CocoaPod_2 |____File contains statement (import cocoapod_1) <---Gives error ld: framework not found

Upvotes: 0

Views: 88

Answers (1)

sandpat
sandpat

Reputation: 1485

You need to do the following two additional things:

  • You need to add a Podfile in your CocoaPod_2 followed by a pod install.

  • Also, you need to define a CocoaPod_2.podspec file in your CocoaPod_2 folder.

If you add Alamofire in both the Podfile and podspec file of CocoaPod_2, you don't need to add in the main app's Podfile. Only adding CocoaPod_2 entry in the app's Podfile will suffice.

I hope that helps!

Upvotes: 0

Related Questions