I have written a static library which interfaces with a web service for internal use across multiple projects.
This library uses AFNetworking
heavily, but so do the projects which will use the library. If I include AFNetworking
in the library.
I get duplicate symbol errors, but if I remove AFNetworking
from the library, it won't compile.
How should I address this dependency ?
Edit: My project is in a GIT repository. Whatever I do, other developers should be able to pull the project and have it compile successfully (unless I am wrong and I shouldn't be that way).
The easiest solution is to rename AFNetworking Classes.
Go to each .m
file of afnetwork, click on class name, then Edit->Refactor->Rename .There are around 10 files. It wouldn't take you long.
PS: A good practise is to prepend your library initials, for example if your library name is MyLibrary, you can rename AFNetworking classes like MyLibAFNetworking... MyLibAFHTTP....
Use Cocoapods, you can add the dependency for AFNetworking and it will automatically add the library and everything will work like a charm. https://cocoapods.org/
Copy the files of AFNetworking project and add them to your project as files of your library. In other words,
Cheers!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.