Question

CocoaPods question:

I have created a framework bundled with a static library inside, depending on AFNetworking and a resource bundle (based on those two tutorials to create FWKs http://www.blackjaguarstudios.com/blog/programming/2012/11/22/xcode-45-creating-ios-framework-and-hold-my-hand-im-3-years-old and https://github.com/bclubb/iOS-Framework)

I'd love to create a podspec so that people just add a line in their Podfile, which would, on pod install, add my framework and the AFNetworking, if needed.

Is this possible?

Was it helpful?

Solution

I have actually done this a lot at my office. We have tons of private source code that is re-used quite a bit. CocoaPods has helped get new projects started much quicker and makes them a whole lot easier to update.

While it is possible to add your framework to the podspec, I have found it much easier to just pass the static library and headers over via CocoaPods rather than worry about the framework.

You will have to update your podspec based on your project, but here are the important parts:

s.source_files = 'StaticLib/Headers/*.h'
s.preserve_paths = 'StaticLib/libYourLibrary.a'
s.library = 'YourLibrary'
s.xcconfig = { 'LIBRARY_SEARCH_PATHS' => '$(PODS_ROOT)/ProjectFolder/LibraryFolder' }    

s.dependency = 'AFNetworking'

This will copy your static library over as well as bring over AFNetworking with your pod too. This will make your static lib much smaller (not having to build it in) and speed up how quickly the user can import your pod.

If you must use framework, the same stuff from above still applies, but you might have some slight tweaking to do. All a framework is is a pretty folder structure for a static lib and headers anyway, so why bother with the extra stuff. The source is all still built into the lPods.a static lib anyway. Hope this helps you out.

OTHER TIPS

In fact you can create your own libxxx.a or xxxx.framework with Cocoapods now. Cocoapods will take care the details such as universal binary and public headers. Pls Check: https://guides.cocoapods.org/making/using-pod-lib-create.html and http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top