Objective c 静态库与弱逻辑系统

Objective c 静态库与弱逻辑系统,objective-c,linker-errors,Objective C,Linker Errors,我构建了一个静态库,它链接到其他框架,特别是CoreLocation。我想使用iOS 5提供的功能,但要与4.3兼容 当我在4.3版本的iOS设备上启动应用程序时,我的应用程序在启动时崩溃,并出现以下错误: Date/Time: 2012-08-22 16:44:53.900 +0200 OS Version: iPhone OS 4.3.3 (8J3) Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTR

我构建了一个静态库,它链接到其他框架,特别是CoreLocation。我想使用iOS 5提供的功能,但要与4.3兼容

当我在4.3版本的iOS设备上启动应用程序时,我的应用程序在启动时崩溃,并出现以下错误:

Date/Time:       2012-08-22 16:44:53.900 +0200
OS Version:      iPhone OS 4.3.3 (8J3)
Report Version:  104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000001, 0xe7ffdefe
Crashed Thread:  0

Dyld Error Message:
  Symbol not found: _UIKeyboardDidChangeFrameNotification
我遇到的问题在本文中有描述:

但是,在构建静态库时,如何处理这个问题??设置-weak lSystem标志时无法编译。以下是一个跟踪:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified, -all_load invalid
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: -dynamic not specified the following flags are invalid: -ObjC 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -weak-lSystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -weak-lSystem is not an object file (not allowed in a library)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libxml2.2.dylib is a dynamic library, not added to the static library
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libxml2.2.dylib is a dynamic library, not added to the static library
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool failed with exit code 1
已解决


请参阅下面接受的答案,不要忘记在Xcode中将不同版本中使用的库标记为可选库。例如:我在iOS5上使用UIKit新通知,但我的部署目标是4.3,因此我需要将此库标记为可选库,以使其正常工作。CoreLocation CLGeocoder新的iOS 5类也是如此。

问题是iOS 4上没有UIKeyboardDidChangeFrameNotification,因此动态加载程序(Dyld)失败


从静态库开发人员的角度来看,您不必做任何事情。应在将静态库用于应用程序的Xcode项目中设置-weak lSystem标志(请参阅问题中提到的帖子),而不是在静态库的项目中设置-weak lSystem标志。

我尝试弱链接动态库,但没有成功。我还试图添加动态标志,但它甚至是最糟糕的!耶!但您还需要将多个版本(例如:UIKit或CoreLocation)中使用的库标记为可选!