Objective-C static libraries and categories

If you are building iPhone or other Mac apps with the iPhone using static libraries, reading
Technical Q&A QA1490 will help you. I was getting a problem running with FMDB because it uses categories to extend the functionality of one of its classes and failing at runtime with a selector problem.

To resolve this issue, the static library should pass the -ObjC option to the linker. This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.

In my case I had to put these flags on the primary application target (the one using the library) rather than the library itself, which strikes me as odd.

  Permalink |  Comments[3]


Related Items


Recent Entries

 » iTunes 8 on Windows XP x64
 » iPhone SDK Code Signing Insights
 » Making iPhone Distribution Profiles Show Up
 » Objective-C static libraries and categories
 » A fix for Textile on Wordpress


You can skip to the end and leave a response. Pinging is currently not allowed.



3 Responses to “Objective-C static libraries and categories”

  1. Mark Says:

    Great Tip!

  2. geeknurse Says:

    You made my day! :D

Leave a Reply

 
 

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a