I'm developing an iPad application which relies on two static utility libraries (libBFSDK & libBetfair-Platform). Both static libraries include AFNetworking. When I try to include the two static libraries in my iPad application, I get a linking error like:
duplicate symbol _OBJC_METACLASS_$_AFImageCache in:
/Users/osheas/Library/Developer/Xcode/DerivedData/Betfair-gnnjnwtovdmtoxakuxbjyvetciyy/Build/Products/Debug-iphonesimulator/libBFSDK.a(UIImageView+AFNetworking.o)
/Users/osheas/Library/Developer/Xcode/DerivedData/Betfair-gnnjnwtovdmtoxakuxbjyvetciyy/Build/Products/Debug-iphonesimulator/libBetfair-Platform.a(UIImageView+AFNetworking.o)
ld: 86 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
UIImageView+AFNetworking is part of AFNetworking. Both static libraries include AFNetworking. As a result, I get duplicate symbols for UIImageView+AFNetworking.
Anyone have ideas on a workaround for this? I have access to the source code for the two static libraries, but I'm still not sure how to solve this problem.
Thanks & please let me know if you need any other details,
Sean
PS - FWIW I'm running Xcode 4.5 & I need to be able to deploy to iOS 4.x devices.
Since you have access to the source for the static libs, you could use the preprocessor to rename the AFNetworking symbols to something unique.
Add flags for each duplicate symbol to your "Other C Flags" build setting with the format
-AFNetworkingSymbol=UniqueAFNetworkingSymbol
This will still result in duplicate code, but should allow you to have multiple copies of AFNetworking without modifying the source.
More info
Ideally, most open source Obj-C code will move to solutions like CocoaPods and just specify dependencies instead of bundling them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With