开发者

Static library woes in iPhone 3.x with categories and C libraries

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, a mm file).

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 (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 devic开发者_如何学JAVAe, 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?


Instead of -all_load you could try to use -ObjC which should make the linker aware of Objective-C categories without loading all symbols (in some cases this works for me, in others it doesn't).

Another workaround would be not to include the MiniZip library into your project (A), but only the header files (which are the only files needed to correctly compile your project). The linker will then use the MiniZip library which was linked to your static library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜