美文网首页iOS收藏iOS 技术文档收录专业知识分享(iOS)
Xcode编译报错的那些坑 (不定时更新)

Xcode编译报错的那些坑 (不定时更新)

作者: Season_希晨 | 来源:发表于2015-06-09 23:08 被阅读3656次

在开发过程中,因为各种客观原因会使用不同版本的Xcode,如5.11. 6.1 6.2等等,而Xcode总是莫名其妙的报错T_T。 这里总结一些坑爹错误解决,简直是本人血泪历程。

1.Xcode6环境下打包静态库,在Xcode5项目中编译报错!

ld: framework not found Metal for architecture armv7

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

下面是我当时搜出的解决方法:
第一篇博客给出的解释是:使用xcode6编译就可以了。这个是因为使用的三方的.a文件是使用xcode6编译的,使用xcode5编译就会出现这个问题。xcode6会莫名其妙的链接Metal.framework
http://blog.sina.com.cn/s/blog_8d663a9c0102v63c.html

但是我公司的项目里只能用Xcode 5编译,所以还是没解决。终于找到外国友人的答案了。
https://www.appsee.com/blog/dev/xcode-new-link-frameworks-automatically-fix-framework-not-found-metal-for-architecture-armv7

The reason behind this, is actually a bug / bad design by Apple, which failed to preserve backward compatibility for non-Metal devices (namely: armv7 & armv7s).
In XCode 5, Apple introduced a new linker flag, named “Link Frameworks Automatically”, which defaults to “YES”. The purpose of this flag is to reduce the effort required by developers when adding a framework. Before the introduction of this flag, developers had to link their projects with system frameworks prior to using them. This flag allows them to simply use the frameworks.

打包静态库的时候,有一个Link Frameworks Automatically设置,默认为YES,会自动链接框架。所以Xcode 6打包的静态库.a文件,在Xcode 5项目编译时候会提示找不到Metal的。

正确的解决方法:打包静态库时,Build Settings 中 Link Frameworks Automatically 把默认Yes 改成 No! 静态库就不会自动链接Metal了。

本人Github博客地址

相关文章

网友评论

  • JYou:xcode9 设置Link Frameworks Automatically为 YES时,其他库也链接不上了,还是不能兼容Xcode8
  • 偶是星爷:Xcode9也有这个问题,呵呵
    上发条的树:@hnxyzhw 请问下,我在自家framework工程中,导入第三方(IEagle)framework可以编译成功。如果是将自家framework(已导入第三方framework)导入可执行工程,就会报类似这样的错:
    ld: framework not found IEagle for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    有没有好的解决方式呢?导入framework的步骤是对的。
    田心今心九日:奇怪了,刚开始用Xcode9的时候Xcode7还可以,后来就不行了,倒腾一天了,也重装了,还没有找到是什么原因,老是提示这个
    hnxyzhw:我也是刚遇到这个类似的错误,修改这个选项可以解决这个错误么ld: framework not found FileProvider for architecture arm64

本文标题:Xcode编译报错的那些坑 (不定时更新)

本文链接:https://www.haomeiwen.com/subject/szcjqttx.html