Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CocoaPods: use static lib into a pod

I have a pod that depends on a static lib (precompiled, source code not available).

In this pod project, i drag and drop the folder containing the ".a" file and some other C, Obj-c files.

When i try to include this pod in an application, Cocoapods copy all that pod files but not the ".a" file.

In the Podspec, im using this to include the precompiled library to my pod

  s.ios.vendored_frameworks = 'path/a_staticLib.a'

The line above copy the file in frameworks (Pods folder), this is normal as it is called "vendored_frameworks", but i can't found any solution to work with static library.

the error i have :

ld: framework not found -framework
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thank you.

like image 980
Red Mak Avatar asked Jan 29 '18 15:01

Red Mak


People also ask

Is CocoaPods static or dynamic?

CocoaPods pod-linkage plugin. In SwiftKey, we have a dynamic framework that we use to share code between the app and the keyboard extension, and all the pods are linked statically except for some of them that are linked dynamically because they are linked to the app and keyboard extension too.

How do you add dependency in CocoaPods?

After you have initially installed CocoaPods into your project, you can add new dependencies (or remove unused ones) by editing the Podfile. Then simply run pod install again.

What is difference between static and dynamic framework?

Static and Dynamic Frameworks:Static frameworks contain a static library packaged with its resources. Dynamic frameworks contain the static/dynamic library with its resources. In addition to that, dynamic frameworks may conveniently include different versions of the same dynamic library in the same framework.


1 Answers

As said in CocoaPods Podspec documentation, you need to use vendored_libraries for static libraries.

So this line:

s.ios.vendored_frameworks = 'path/a_staticLib.a'

should be:

s.ios.vendored_libraries = 'path/a_staticLib.a'
like image 100
Larme Avatar answered Sep 18 '22 00:09

Larme