My podspec requires a static library (OpenSSL). For convenience, I'm shipping the library with the pod.
The static library contains:
- Binaries:
MyPod/openssl/bin/libcrypto.a
andMyPod/openssl/bin/libsll.a
- Headers:
MyPod/openssl/include/openssl/*.h
- Its own license (in addition to my project's license):
MyPod/openssl/include/LICENSE
What is the proper way of expressing this in my podspec? I've seen various example that use combinations of the following properties and I'm currently trying different combinations:
source_files
public_header_files
private_header_files
preserve_paths
libraries
xcconfig
vendored_libraries
Or even better, can I define this static library in a subspec?
You can try do it like it's done here https://github.com/krzak/OpenSSL, or just use this Pod with you project if you find it convienence
I managed to add the static library as a
subspec
. I prefer this approach because it uses the build shipped with my pod by default, and also enables users to provide their own build if they so desire.As mentioned, the static library is OpenSSL but the following applies to any static library. I'm using the following directory structure:
The resulting subspec would be:
Line by line:
Preserve headers and the license file. We will use the headers below.
Tell CocoaPods that we are shipping the above static libraries in the pod. This will preserve the files, as well as modifying
LIBRARY_SEARCH_PATHS
accordingly.Includes the libraries in "Other Linker Flags".
Tells the project where to find the headers. We cannot use
public_header_files
because this is asubspec
.