I have an app that links to my static library.
I've just added Apple's Reachability Code to the library however this has caused the app to stop linking (even though app does not use the reachability code, nor is it including it indirectly, in addition Reachability.m is contained within the library's Compile Sources section).
So I added -ObjC to Other Linker Flags in the app and this solved the linking errors for Reachability. However the library is also using ZipArchive and adding the -ObjC linker flag caused linking errors related to that.
So what can I do? Leave -ObjC off and Reachability doesn't link, include it and ZipArchive doesn't link. Is there a solution?
Sample ZipArchiev linker error:
Undefined symbols for architecture arm64:
"_deflate", referenced from:
_zipWriteInFileInZip in libMyLibrary.a(zip.o)
_zipCloseFileInZipRaw in libMyLibrary.a(zip.o)
Sample Reachability linker error:
Undefined symbols for architecture arm64:
"_SCNetworkReachabilityGetFlags", referenced from:
-[Reachability connectionRequired] in libMyLibrary.a(Reachability.o)
-[Reachability currentReachabilityStatus] in libMyLibrary.a(Reachability.o)
The static library is being built with the -ObjC flag and it links with libz.1.2.5.dylib
I do actually have a solution which I found after initially posting this - I can add the -ObjC flag to the app and additionally link the app with libz.1.2.5.dylib. But IMO that is not good decoupling - my static library is going to be distributed and used by other people's apps and the fact it uses libz should be transparent to them and they should not have to link against it if they are already linking against my library. Is there a way I can solve the linking issue without the apps having to link both against my static library and the libz dynamic library?