简体   繁体   English

适用于iOS3和iOS4的iPhone静态库

[英]iPhone Static Library for iOS3 and iOS4

I'm trying to build a universal binary from a static library that works for both ios4 and ios3. 我正在尝试从适用于ios4和ios3的静态库构建通用二进制文件。 However, when I add the library built in ios4 and try to use it in ios3 it gives me these kinds of errors: 但是,当我添加内置于ios4的库并尝试在ios3中使用它时,会出现以下几种错误:

Undefined symbols: "_OBJC_CLASS_$_NSMutableCharacterSet", referenced from: objc-class-ref-to-NSMutableCharacterSet in myLib.a(myLib.a-i386-master.o) "_OBJC_CLASS_$_NSURLConnection", referenced from: objc-class-ref-to-NSURLConnection in myLib.a(myLib.a-i386-master.o) "_OBJC_CLASS_$_UIDevice", referenced from: objc-class-ref-to-UIDevice in myLib.a(myLib.a-i386-master.o) "_OBJC_CLASS_$_NSString", referenced from: 未定义符号:“ _ OBJC_CLASS _ $ _ NSMutableCharacterSet”,引用自:myLib.a中的objc-class-ref-to-NSMutableCharacterSet(myLib.a-i386-master.o)“ _ OBJC_CLASS _ $ _ NSURLConnection”,引用自:objc-class-ref myLib.a(myLib.a-i386-master.o)中的-to-NSURLConnection“ _OBJC_CLASS _ $ _ UIDevice”,引用自:myLib.a(myLib.a-i386-master中的objc-class-ref-to-UIDevice。 o)“ _OBJC_CLASS _ $ _ NSString”,引用自:

I can't combine the library built in ios3 and ios4 with lipo because they use the same architecture. 我无法将ios3和ios4中内置的库与lipo结合使用,因为它们使用相同的体系结构。 It looks like it's just not finding some basic files from UIKit. 似乎只是从UIKit中找不到一些基本文件。 Do I just need to fix some linking issues? 我是否只需要解决一些链接问题?

Try weak-linking UIKit. 尝试弱链接UIKit。 In your build settings right now, it's probably tagged as "Required". 现在,在您的构建设置中,它可能被标记为“必需”。

(Right-click target -> Get Info -> General tab -> Linked Libraries -> "Type" column for UIKit.framework) (右键单击目标->获取信息->常规选项卡->链接的库-> UIKit.framework的“类型”列)

Just make sure all code paths used by an iOS 3 build aren't using iOS 4.x-only stuff. 只要确保iOS 3构建使用的所有代码路径都没有使用仅限iOS 4.x的东西即可。

Have you tried adding 您是否尝试过添加

#import <UIKit/UIKit.h>

...to the top of your class .h file? ...到类.h文件的顶部? That might fix the problem. 那可能会解决问题。

Andy 安迪

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM