Using cocoapods within

I have created an iOS framework that uses a library (RestKit) via CocoaPods. In an application project using my framework, I also use CocoaPods to include other libraries. I had to include the library from the framework as the project would not compile otherwise.

Everything works fine, but as expected when starting the application I get: Class X is implemented as in / private / var / mobile / Containers / Bundle / Application / [...] / Application.app/Frameworks/Framework.framework/ Framework and / private / var / mobile / Containers / Bundle / Application / [...] / Application.app/Application. One of the two will be used. Which one is undefined. "In several classes from libraries.

Is there a way in CocoaPods or in the build process to prevent duplicate libraries when they are already in use?


Another context for my question. Here's what I did:

  • Created an infrastructure project as Cocoa Touch Framework. Initially, I only added a Podfile with a dependency for RestKit like this:
    pod 'RestKit', '~>0.23'


    Then I removed the subfile and just added the podspec like @Paula Chavarría's comment.

  • Created an application project. Added a Podfile with other dependencies, as well as a framework dependency that @Paula Chavarría also mentioned.

When I create an application project, the framework is down because it cannot find the correct headers. I changed the header search path for the framework, but it doesn't seem to be enough for the build to be successful.

Should I have a sub-file within? As I said in my original question, I did it first and I ended up with duplicate libraries and what I am trying to avoid in the first place. Is there a way to customize the Podfile or the configurations it generates and use the headers in the application and link them to the application libraries? What am I missing here? ... Thanks in advance! :)

+3


source to share


1 answer


If you are using Cocoapods in your app project, you can create a private module for the iOS framework. To do this, you need to create a .podspec file to add the conflicting dependency. For Restkit, the .podspec file will look like this:

Pod::Spec.new do |s|

 s.name         = "MyFramework"
 ...
 s.dependency 'RestKit', '~> 0.23'

end

      

You can read more about these files here: http://guides.cocoapods.org/making/specs-and-specs-repo.html



After that, you just need to add your framework dependency in the Podfile project. You can do this through your local path or through source control.

pod 'MyFramework', :path => './../my-framework'

pod 'MyFramework', :git => 'https://url/to/my-framework.git', :tag => '0.0.1'

      

+3


source







All Articles