简体   繁体   English

xcode LLVM 5.1 clang错误

[英]xcode LLVM 5.1 clang error

I am having no luck the last few days since Xcode 5.1 came out. 自Xcode 5.1问世以来的最后几天,我没有运气。

I keep getting this error on an old project that supports iOS 6.0: 我一直在支持iOS 6.0的旧项目上遇到此错误:

ERROR:

clang: error: unknown argument: '-fno-obj-arc' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

There are not many posts about this on the internet and some suggestions seem to be to change your CFLAGS but I have no idea how to do that in Xcode. 在互联网上关于这一点的帖子不多,一些建议似乎是要改变你的CFLAGS但我不知道如何在Xcode中做到这一点。

Apple suggests this from their documents: Apple从他们的文件中建议:

Compiler 编译器

As of Apple LLVM compiler version 5.1 (clang-502) and later, the optimization level -O4 no longer implies link time optimization (LTO). 从Apple LLVM编译器版本5.1(clang-502)及更高版本开始,优化级别-O4不再意味着链接时间优化(LTO)。 In order to build with LTO explicitly use the -flto option in addition to the optimization level flag. 为了使用LTO进行构建,除了优化级别标志外,还要使用-flto选项。 (15633276) The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. (15633276)Xcode 5.1中的Apple LLVM编译器将无法识别的命令行选项视为错误。 This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified. 在构建Python本机扩展和Ruby Gems时已经看到了这个问题,其中当前指定了一些无效的编译器选项。 Projects using invalid compiler options will need to be changed to remove those options. 需要更改使用无效编译器选项的项目以删除这些选项。 To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning: 为了帮助简化转换,编译器将暂时接受将错误降级为警告的选项:

-Wno-error=unused-command-line-argument-hard-error-in-future

Note: This option will not be supported in the future. 注意:将来不支持此选项。 To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning. 要解决此问题,请将ARCHFLAGS环境变量设置为将错误降级为警告。 For example, you can install a Python native extension with: 例如,您可以使用以下命令安装Python原生扩展:

$ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install ExtensionName

Similarly, you can install a Ruby Gem with: 同样,您可以安装Ruby Gem:

$ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName 16214764 updated

How do I get this workaround? 我如何获得此解决方法? Obviously Apple has messed up because it should only be presenting me with a warning and not an error according to their documents. 显然苹果已经搞砸了,因为它只应该根据他们的文件向我发出警告而不是错误。

Any help would be greatly appreciated. 任何帮助将不胜感激。 I can not build my app until this issue is rectified. 在此问题得到解决之前,我无法构建我的应用程序。

There is no such thing as -fno-obj-arc . 没有-fno-obj-arc类的东西。 This never was working correctly; 从来没有正常工作; you just weren't seeing the warnings. 你只是没有看到警告。 The correct form is -fno-objc-arc . 正确的形式是-fno-objc-arc

EDIT (appended info drawn from my comments below): This is not a clang error. 编辑(从我下面的评论中提取的附加信息):这不是一个铿锵的错误。 It is an error in the project; 这是项目中的一个错误; clang is merely reporting it. clang只是报道它。 The project itself wrongly contains the -fno-obj-arc argument, probably in the Compile Sources build phase of the target (as described here: How can I disable ARC for a single file in a project? ). 项目本身错误地包含-fno-obj-arc参数,可能在目标的Compile Sources构建阶段(如下所述: 如何为项目中的单个文件禁用ARC? )。 It is easy to type the setting incorrectly; 很容易输入错误的设置; what has changed in Xcode 5.1 is merely that clang is now calling the problem to your attention. Xcode 5.1中发生的变化仅仅是clang现在正在引起你的注意。 Thus, as I said before, this never was working correctly; 因此,正如我之前所说,这从来没有正常工作; you presumably intended to turn off ARC for certain files, but you were failing to do so, as the build argument was incorrectly entered. 你可能想要关闭某些文件的ARC,但你没有这样做,因为构建参数输入错误。

Update to xcode now throws unknown compiler flags as hard errors rather than warnings. 现在更新到xcode会将未知的编译器标志作为硬错误而非警告抛出。 Found this to be helpful: 发现这有用:

https://langui.sh/2014/03/10/wunused-command-line-argument-hard-error-in-future-is-a-harsh-mistress/ https://langui.sh/2014/03/10/wunused-command-line-argument-hard-error-in-future-is-a-harsh-mistress/

I figured out with a small bit of help from matt. 我发现了一些来自亚光的帮助。
I was trying to figure out where to change the -fno-obj-arc and NO ONE answered that question. 我试图找出改变-fno-obj-arc的位置,NO ONE回答了这个问题。 I found this link to be helpful... http://blog.evanmulawski.com/?p=36 我发现此链接很有帮助... http://blog.evanmulawski.com/?p=36

Once you select build phases and compile sources, you can look next to the files in your project and change their build flags. 选择构建阶段并编译源代码后,您可以查看项目中的文件旁边的内容并更改其构建标志。

Thanks for the attempt guys. 谢谢你的尝试。

export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"

You need to change -fno-obj-arc to -fno-objc-arc. 您需要将-fno-obj-arc更改为-fno-objc-arc。 Select project -> targets -> build phases ..see picture 选择项目 - >目标 - >构建阶段..查看图片 在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM