`
xiaoheliushuiya
  • 浏览: 396881 次
文章分类
社区版块
存档分类
最新评论

使用XCode5和iOS7SDK出现Undefined symbols for architecture i386 clang: error: linker command failed with

 
阅读更多

下载好最新的Xcode5 preview版程序并安装后,开始进行iOS7程序开发了!

新建project,在不添加文件的情况下,应用程序运行正常。那就开始编写自己的程序了,添加一个没有任何工程的类,例如添加一个继承UIVIewController类ViewController,在AppDelegate.m新建一个新的ViewController实例,编译,居然出现了如下的错误:

Undefined symbols for architecture i386:

"_OBJC_CLASS_$_ViewController", referenced from:

objc-class-ref in AppDelegate.o

ld: symbol(s) not found for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

可以看到错误描述是:在链接ViewController时出现了错误,其实该错误出现的原因有:

1、你用模拟器作为目标,但编译的时候找不到相关的库文件,需要做的就是把库文件所在的位置添加到library search path中;

2、没有将ViewController.m文件放入target 的"Build Phases" 项的"Compile Sources" 。本来Xcode应该替我们完成的,可是Xcode5 preview版就没有做这件事,所以需要手动添加了,否则就会出现上面的错误;如图:

3、stackoverflow上面还提供了很多某些场景下的解决方法:

例如,当打开同一个项目两次,其中一个是原始的,而另一个是从git url 克隆而来,也出现了上面的问题,这时的解决方法是——'Product' > 'Clean' solved the problem.

4、更多的解决方法参考:

http://stackoverflow.com/questions/6984368/undefined-symbols-for-architecture-i386-objc-class-skpsmtpmessage-refere

http://stackoverflow.com/questions/6610709/undefined-symbols-for-architecture-i386

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics