iOS静态库的向后兼容性
我正在创建一个 iOS 静态库并尝试集成新的 iOS5 Twitter 框架。所以我实现了新的 Twitter 框架并制作了库,静态库将在 Xcode 4.2 (iOS5) 上运行,没有任何问题。 我的问题是,该库无法与旧版 iOS SDK 一起使用,因为 Twitter 框架不存在。当我尝试在 XCode 4.02 中使用该库时,出现以下错误:
架构 i386 的未定义符号:
“_OBJC_CLASS_$_TWTweetComposeViewController”,引用自: libTest.a(TestViewController.o) ld 中的 objc-class-ref: 未找到体系结构 i386collect2 的符号:ld 返回 1 退出 状态
这里 libTest.a 是我正在尝试制作的静态库。
所以基本上我想要实现的是,使用 Xcode 4.2 (iOS 5 SDK) 编译静态库并在 Xcode < 中使用它。 4.2(即iOS SDK < 5)不会导致错误。即,静态库应该在 iOS-5 SDK 中显示新的 Twitter APi,在旧版 iOS SDK 中显示我自己的 OAuth Twitter 视图。
I am creating an iOS static library and trying to integrate the new iOS5 Twitter framework. So I have implemented the new Twitter framework and made the library, the static library will work on Xcode 4.2 (iOS5) without any problem.
The problem with me is that, the library wont work with the older iOS SDK since the Twitter Framework are not present. I get the following error when I try to use the library in XCode 4.02 :
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_TWTweetComposeViewController", referenced from:
objc-class-ref in libTest.a(TestViewController.o) ld:
symbol(s) not found for architecture i386 collect2: ld returned 1 exit
status
Here libTest.a is the static library which I am trying to make.
So basically want I am trying to achieve is, compile a static library with Xcode 4.2 (iOS 5 SDK) and use it in Xcode < 4.2 (ie iOS SDK < 5) without causing error. ie, the static library should show the new Twitter APi in iOS-5 SDK and my own OAuth Twitter views in older iOS SDKs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看“弱链接”的概念。那应该可以解决你的问题。
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/cross_development/Using/using.html#//apple_ref/doc/uid/20002000-SW6
Check out the concept of "weak linking". That should solve your issues.
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/cross_development/Using/using.html#//apple_ref/doc/uid/20002000-SW6
您不能使用在未来版本的 iOS 中引入的框架
You can't use frameworks that were introduced in future versions of iOS