Static library woes in iPhone 3.x with categories and C libraries
- by hgpc
I have a static library (let's call it S) that uses a category (NSData+Base64 from MGTwitterEngine) and a C library (MiniZip wrapped by ZipArchive).
This static library is used in an iPhone 3.x project (let's call it A). To be able to use the MiniZip library I included its files in project A as well as the static library S. If not I get compilation errors.
Project A works fine on the simulator. When I run it on the device, I get unrecognized selector errors when the category is used.
As pointed out here, it seems there's a linker bug that affects categories in iPhone 3.x (http://stackoverflow.com/questions/1147676/categories-in-static-library-for-iphone-device-3-0). The workaround is to add -all_load to the Other Linker Flags of the project that references the static library.
However, if I do this then I get duplicate symbol errors because I included the MiniZip libraries in project A.
A workaround is to include the category files in project A as well. If I do this, project A works well in the device, but fails to build on the simulator because of duplicate symbol errors.
How should I set up project A to make it work on the simulator and the device with the same configuration?