我正在尝试使用静态库,并且其中的类别在运行时没有被使用。没有编译时错误,但是当我开始运行时,我收到标准的“无法识别的选择器发送到实例”消息并且我的应用程序崩溃了。
许多解决方案说要添加-ObjC -all_load
到应用程序目标中的“其他链接器标志”属性(许多其他人说从 XCode 4 开始不再需要,这是我费心包含 XCode 版本的唯一原因)。我已经尝试过了,在构建过程中出现 115 个错误:
Undefined symbols for architecture i386:
"_CLLocationCoordinate2DMake", referenced from:
-[QMapElement init] in libQuickDialog.a(QMapElement.o)
"_OBJC_CLASS_$_MKMapView", referenced from:
objc-class-ref in libQuickDialog.a(QMapViewController.o)
"_OBJC_CLASS_$_MKPinAnnotationView", referenced from:
objc-class-ref in libQuickDialog.a(QMapViewController.o)
"std::istream::gcount() const", referenced from:
GT::AES::decode(std::istream&, std::ostream&, unsigned int&, bool) in GD(gtaes.o)
GT::AES::encode(std::istream&, std::ostream&, unsigned int&, bool) in GD(gtaes.o)
"std::string::find_first_of(char const*, unsigned long, unsigned long) const", referenced from:
-[GDSetPasswordViewController checkPasswordStrength:] in GD(GDSetPasswordViewController.o)
GD::EacpCReq::EacpCReq(std::string, std::string, GT::Dbb&) in GD(GDEacpCommands.o)
GD::RawSocket::connect() in GD(GDRawSocket.o)
"std::string::copy(char*, unsigned long, unsigned long) const", referenced from:
GD::Socket::toString() const in GD(GDSocket.o)
(依此类推,大约是 115 个中的 5 个或 6 个)。
无论我有这些链接器标志中的任何一个,还是两者都有,我都会得到完全相同的错误集。
不确定这是否是罪魁祸首,或者只是巧合,但在更仔细地查看错误之后,似乎它们都来自我正在使用的两个 3rd 方库之一。一个作为已安装的 .framework,另一个作为常规静态库。也许我也需要对他们的构建做点什么(如果可能的话)?谢谢!