1

我正在尝试将 HessianKit 与一个简单的 Xcode iOS 测试项目联系起来。我尝试了不同的构建配置。我将 -ObjC 开关添加到库项目和我的主项目的链接器命令行。

这是主项目的命令行:

Ld /Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator/MatthiasSimpleTest.app/MatthiasSimpleTest normal i386
cd /Users/wuttke/Documents/MatthiasSimpleTest
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator -L/Users/wuttke/Documents/MatthiasSimpleTest/MatthiasSimpleTest -L/Users/wuttke/Documents/MatthiasSimpleTest -F/Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator -F/Users/wuttke/Documents/MatthiasSimpleTest -filelist /Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Intermediates/MatthiasSimpleTest.build/Debug-iphonesimulator/MatthiasSimpleTest.build/Objects-normal/i386/MatthiasSimpleTest.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework UIKit -framework Foundation -framework CoreGraphics -framework HessianKit -o /Users/wuttke/Library/Developer/Xcode/DerivedData/MatthiasSimpleTest-gfekzjmarzscwwgbynkuztivwkpw/Build/Products/Debug-iphonesimulator/MatthiasSimpleTest.app/MatthiasSimpleTest

这是来自链接器的错误消息:

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_CWHessianConnection", referenced from:
      objc-class-ref in MainWindowController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我附上了一个显示项目的屏幕截图(它包含 HessianKit.framework,我们为 i386/MacOS、iOS 5.0 构建)。

截图失败

这是一些输出,显示要链接的库的内容:

Tobiass-MacBook-Pro:HessianKit.framework wuttke$ pwd
/Users/wuttke/Documents/MatthiasSimpleTest/HessianKit.framework
Tobiass-MacBook-Pro:HessianKit.framework wuttke$ ls
Headers     HessianKit  Resources   Versions
Tobiass-MacBook-Pro:HessianKit.framework wuttke$ nm -arch i386 HessianKit | grep CWHessianConnection
000010a0 t +[CWHessianConnection proxyWithURL:protocol:]
00001020 t -[CWHessianConnection initWithHessianVersion:]
000011a0 t -[CWHessianConnection proxyWithURL:protocol:]
00001260 t -[CWHessianConnection setVersion:]
00001240 t -[CWHessianConnection version]
0000d000 S .objc_class_name_CWHessianConnection

我发现了尝试将 HessianKit 文件直接包含在项目中的建议。由于 ARC,这会产生编译错误。

你有什么建议我可以试试吗?提前非常感谢。

马蒂亚斯

4

1 回答 1

0

我对 Xcode 很陌生,并且能够解决这个问题。我试图在我正在开发的项目中使用 HessianKit。

这篇文章中描述了该问题的解决方案:https ://stackoverflow.com/a/7866167/1366367

显然 iPhone 模拟器需要为i386架构而不是armv7构建的库。

这对我有用:

  1. 打开项目 HessianKit(从 sourceforge 下载)
  2. 将 HessianKit 目标上的 Base SDK 设置为iphonesimulator
  3. 为 StaticHessianKit 目标清除 Base SDK(应默认为 iphonesimulator)
  4. 运行构建
  5. ~/Library/Developer/Xcode/DerivedData/*/Build/Products/Debug-iphonesimulator文件夹中找到 libStaticHessianKit.a
  6. 将 libStaticHessianKit.a 拖到您的项目中。这应该会自动设置库搜索路径。
  7. 将 HessianKit 框架文件夹也拖到您的项目中。
  8. 确保在使用 HessianKit 的地方导入它:

    #import <HessianKit/HessianKit.h>
    

祝你好运。

于 2012-05-07T05:46:47.200 回答