Search code examples
iosxcodestatic-linkingobjective-c++

Static library use


I have a static library that has another static library inside of it.
Let's call them LibA and LibB.
LibA is the outward facing library or in other words, LibA calls on LibB internally and LibB has no outward facing function calls.
LibA's header is extern C so that the names do not get mangled.
I have tested this library using Swift and it works flawlessly.
However when I try to use it inside of a Obj-C project, I get the following errors :

 "_OBJC_CLASS_$_UIResponder", referenced from:


  _OBJC_CLASS_$_AppDelegate in AppDelegate.o


  "_OBJC_CLASS_$_UIViewController", referenced from:


  _OBJC_CLASS_$_ViewController in ViewController.o


 "_OBJC_METACLASS_$_UIResponder", referenced from:


 _OBJC_METACLASS_$_AppDelegate in AppDelegate.o


"_OBJC_METACLASS_$_UIViewController", referenced from:


 _OBJC_METACLASS_$_ViewController in ViewController.o


 "_UIApplicationMain", referenced from:


 _main in main.o


 ld: symbol(s) not found for architecture x86_64


 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have made sure that both LibA and LibB are built for the architecture x86_64.
Any help is much appreciated.

Edit: I was able to solve this issue. Under the Build Phases, I had to add the UIKit.framework to the Link Binary with Libraries. This fixed the errors and allowed me to use my Library. Thank you for the help!


Solution

  • Add UIKit.framework to your app's target.