静态库使用

Static library use

我有一个静态库,里面有另一个静态库。
我们称它们为 LibA 和 LibB。
LibA 是面向外的库,或者换句话说,LibA 在内部调用 LibB,而 LibB 没有面向外的函数调用。
LibA 的 header 是 extern C,因此名称不会被破坏。
我已经使用 Swift 测试了这个库,它运行完美。
但是,当我尝试在 Obj-C 项目中使用它时,出现以下错误:

 "_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)

我已确保 LibA 和 LibB 都是为架构 x86_64 构建的。
非常感谢任何帮助。

编辑:我能够解决这个问题。在构建阶段下,我必须将 UIKit.framework 添加到带有库的 Link 二进制文件。这修复了错误并允许我使用我的图书馆。感谢您的帮助!

UIKit.framework 添加到您应用的目标。