架构i386链接命令退出代码1的未定义符号

时间:2012-07-14 21:36:47

标签: ios xcode

构建模拟器时出现此错误:

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

这是为本地设备(iPad)构建时的那个:

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

尝试了我能想到的一切......你能帮助我吗?

1 个答案:

答案 0 :(得分:4)

Clang非常善于将错误放在人类可读的纯文本中,只是我们有时会看到大局并放弃。看这里:

"_OBJC_CLASS_$_SA_OAuthTwitterController"

现在剥去标准的_OBJC_CLASS_ $部分,你会得到什么? SA_OAuthTwitterController

现在,第二部分:

... referenced from:
  objc-class-ref in NetworkUpdateViewController.o
   "_OBJC_CLASS_$_SA_OAuthTwitterEngine", referenced from:
  objc-class-ref in NetworkUpdateViewController.o
  "_OBJC_CLASS_$_MGTwitterEngine", referenced from:
  objc-class-ref in TwitterLoginViewController.o

显然,您 引用 这个不存在的标题 类命名 NetworkUpdateViewControllerTwitterLoginView

现在,在这一点上,出现了两种可能性:要么就是你没有将正确的文件添加到Compile Sources列表中,要么就是你正在使用一个不是为iOS模拟器(架构i386)构建的框架(或通用图书馆,因为它们经常被称为)。在第一种情况下,找到有问题的实现文件并将它们拖到Compile Sources列表然后构建并运行。如果是第二种情况,那么你必须在设备上进行测试,或者尝试将lib重新编译成一个可用的通用库,它比听起来更难。