1

我正在使用 Xcode 4.6 和默认编译器

选择 Build Settings 选项卡,并进行以下更改(同样,用您的 J2ObjC 的分发目录替换 $distribution-path):

在标题搜索路径中,添加"$distribution-path/include", then add "${DERIVED_FILES_DIR}". 在库搜索路径中,添加"$distribution-path/lib". 在其他链接器标志中,添加"-ljre_emul -ObjC -force_load $distribution-path/lib/libjre_emul.a". (jre_emul is J2ObjC's JRE emulation library).

我相同的设置

"-ljre_emul -Wl-ObjC -force-load ${HOME}/Desktop/j2objc/lib/libjre_emul.a"

-[__NSCFConstantString trim]: unrecognized selector sent to instance 0x1f89c8
2013-06-05 17:50:21.412 TESTJ2OJBC[885:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString trim]: unrecognized selector sent to instance 0x1f89c8'
*** First throw call stack:
(0x314a63e7 0x391a1963 0x314a9f31 0x314a864d 0x31400208 0x61de3 0x716dd 0x9e3d9 0x9d9bf 0x9deeb 0x9d6ab 0x48fe1 0x48de1 0x332d4579 0x33314d59 0x33310af5 0x333521e1 0x48cab 0x33315aa1 0x33315625 0x3330d833 0x332b5d1f 0x332b57ad 0x332b51ef 0x34fcd5f7 0x34fcd227 0x3147b3e7 0x3147b38b 0x3147a20f 0x313ed23d 0x313ed0c9 0x3330c46d 0x333092b9 0x4899f 0x395ceb20)
libc++abi.dylib: terminate called throwing an exception


__NSCFConstantString trim is 
NSString+JavaString.h  method
// String.trim()
- (NSString *)trim;

请教我

4

1 回答 1

1

如果要链接包含类别中的类扩展的静态库,则需要为-objc链接器指定标志。这迫使它从库中加载所有对象,而不仅仅是那些被引用的对象,因此链接器可以将其识别为未解析的外部符号。从技术上讲,我认为链接器可能会更好地识别这些而不需要包含所有内容,但它目前需要这个标志。

于 2013-06-05T13:38:09.957 回答