IOS Framework build: what is the best practice for linking with third party libraries?

I am building a framework for iOS and my framework has AFNetworking as a dependency. So what's the best practice for including AFNetworing? Reading other posts (especially this question here ), I came up with three options:

  • Copy all .hm files from AFNetworing to my project and compile my infrastructure. But according to this , it could lead to a situation where some third part developer using my platform is already using AFNetworking and will get a compile time error declared by some class twice.

  • Use CocoaPods and link AFNetworking to my Framework. This causes this error: -lPods is not an object file (not allowed in the library).

  • Build something like the Aeris SDK where a 3rd party developer using my Framework will responsibly add AFNetworking to their project.

I think option 3 is the best, but I don't know how. How can I protect my infrastructure from AFNetworking class / method calls, but not include it in the final product?

Thank!

+3


source to share


2 answers


Ok. I decided to go with option 3.

And just added all header files from any third party library to my framework project (you can also add .m files, but not include them in the static library target).



And I've documented everything as well, so developers using my framework will know what the dependencies are and how to include / install them in their own projects (including third party libs, CocoaPods support, etc.).

I decided not to go with option 1 because it would cause some situations where the project will have two copies of the same lib compiled in the final application. Even if I change the namespace for the libs in my framework code (to prevent "duplicate symbols" errors) that will still cause some other possible problems, such as a large APP size, possible errors related to two or more instances of the same and the same lib run together, etc.

-1


source


It is very bad practice to use a third party library in your library.
Ideally, you should avoid this.



But if you really need it, you can define and prefix the class names.
See this article Avoiding dependency conflicts in an iOS static library managed by CocoaPods

+3


source







All Articles