Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a static library with cocoapods

I am trying to build a static library that has different dependencies (AFNetworking for example) specified in a Podfile. I don't want the dependencies to be included in the final static library (call libMyProject.a), I just want to link against them and then create a MyProject.Podspec file where I can put the same dependencies.

The problem is that when I build libMyProject.a the libPods.a is linked and included, so that if I distribute libMyProject.a and other people integrates it in a project which uses some of the same dependencies it will have duplicate symbols issues.

How can I link against the libPods.a lib but not include it in libMyProject.a? It should work just like linking with other existing frameworks.

Thanks!

like image 222
javierdfm Avatar asked Jun 13 '13 16:06

javierdfm


People also ask

Will integrating static library pods cause copy script phases to be run?

Integrating static library pods into static library targets will not cause copy script phases to be run CocoaPods 1.5.0 is an exciting release. We're very excited for you to try it out, and recommend you upgrade:

Can I use Objective-C with CocoaPods?

With CocoaPods 1.5.0, developers are no longer restricted into specifying use_frameworks! in their Podfile in order to install pods that use Swift. Interop with Objective-C should just work .

Can I use Objective-C libraries in a swift pod?

However, if your Swift pod depends on an Objective-C, pod you will need to enable "modular headers" (see below) for that Objective-C pod. When CocoaPods first came out many years ago, it focused on enabling as many existing libraries as possible to be packaged as pods.

What's new in CocoaPods?

Just a few months after the release of CocoaPods 1.4.0, we're releasing a new version that focuses on enabling everyone to adopt Swift. Up until Xcode 9, support for building Swift into static libraries was non-existent and use of dynamic frameworks was required.


1 Answers

I solved it by removing the libPods.a lib from the section "Link Binary With Libraries" in Build Phases.

like image 175
javierdfm Avatar answered Sep 30 '22 16:09

javierdfm