ios xcode LLVM 5.1 叮当错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22394575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:44:17  来源:igfitidea点击:

xcode LLVM 5.1 clang error

iosxcodecompiler-constructionllvm

提问by Airtower

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 CFLAGSbut I have no idea how to do that in Xcode.

互联网上关于这个的帖子并不多,一些建议似乎是改变你的,CFLAGS但我不知道如何在 Xcode 中做到这一点。

Apple suggests this from their documents:

苹果从他们的文件中提出了这一点:

Compiler

As of Apple LLVM compiler version 5.1 (clang-502) and later, the optimization level -O4 no longer implies link time optimization (LTO). In order to build with LTO explicitly use the -flto option in addition to the optimization level flag. (15633276) The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified. 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. For example, you can install a Python native extension with:

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

Similarly, you can install a Ruby Gem with:

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

编译器

从 Apple LLVM 编译器版本 5.1 (clang-502) 及更高版本开始,优化级别 -O4 不再意味着链接时间优化 (LTO)。为了使用 LTO 进行构建,除了优化级别标志外,还明确使用 -flto 选项。(15633276) Xcode 5.1 中的 Apple LLVM 编译器将无法识别的命令行选项视为错误。在构建 Python 本机扩展和 Ruby Gems 时已发现此问题,其中当前指定了一些无效的编译器选项。使用无效编译器选项的项目需要更改以删除这些选项。为了帮助缓解这种转变,编译器将暂时接受一个选项,将错误降级为警告:

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

注意:将来将不支持此选项。要解决此问题,请设置 ARCHFLAGS 环境变量以将错误降级为警告。例如,您可以使用以下命令安装 Python 本机扩展:

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

同样,您可以使用以下命令安装 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.

我如何获得此解决方法?显然,Apple 搞砸了,因为根据他们的文档,它应该只向我显示警告而不是错误。

Any help would be greatly appreciated. I can not build my app until this issue is rectified.

任何帮助将不胜感激。在解决此问题之前,我无法构建我的应用程序。

回答by matt

There is no such thing as -fno-obj-arc. This neverwas working correctly; you just weren't seeing the warnings. The correct form is -fno-objc-arc.

没有这样的事情-fno-obj-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. The project itself wrongly contains the -fno-obj-arcargument, 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?). 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. Thus, as I said before, this neverwas 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.

编辑(从我下面的评论中提取的附加信息):这不是叮当声错误。是项目中的错误;clang 只是在报告它。项目本身错误地包含-fno-obj-arc参数,可能在目标的编译源构建阶段(如此处所述:如何为项目中的单个文件禁用 ARC?)。很容易输入错误设置;在 Xcode 5.1 中发生的变化仅仅是 clang 现在提醒您注意这个问题。因此,正如我之前所说,这从来没有正常工作过;您可能打算关闭某些文件的 ARC,但您未能这样做,因为错误输入了构建参数。

回答by daroo

Update to xcode now throws unknown compiler flags as hard errors rather than warnings. Found this to be helpful:

对 xcode 的更新现在将未知的编译器标志作为硬错误而不是警告抛出。发现这很有帮助:

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/

回答by Airtower

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. I found this link to be helpful... http://blog.evanmulawski.com/?p=36

我在马特的帮助下想通了。
我试图找出在哪里更改 -fno-obj-arc 并且没有人回答这个问题。我发现这个链接很有帮助... 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.

谢谢你们的尝试。

回答by msc

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

回答by Juraj Antas

You need to change -fno-obj-arc to -fno-objc-arc. Select project -> targets -> build phases ..see pictureenter image description here

您需要将 -fno-obj-arc 更改为 -fno-objc-arc。选择项目 -> 目标 -> 构建阶段..见图在此处输入图片说明