Question

I followed the instructions in this article to create a static library:

http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html

I built it for iPhone simulator target. It built successfully, then I imported into a new project where I wanted to use it. It imported fine and there are no problems, but the library doesn't work. There are no library methods that I'm calling; rather the purpose of the library is to swizzle the UIViewController viewDidAppear method so that a piece of code gets executed every time a UIViewController appears. This piece of code is not getting called, despite my library being included in the "Link Binary With Libraries" build phase.

I know the problem isn't with the code itself because if I import the raw .m and .h source files not as a library, everything works fine.

Was it helpful?

Solution

Did your library contain any categories?

If so, I think you should follow these steps to get it work:

  1. In Xcode, double-click the target's name under "Targets" in the Project window.
  2. Choose the Build Settings panel.
  3. Scroll down to the "Other Linker Flags" build setting under the Linking collection and set its value to "-all_load -ObjC".

Please refer to corresponding Apple Documentation

Here is a related question: Objective-C categories in static library

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top