10

I am having no luck the last few days since Xcode 5.1 came out.

I keep getting this error on an old project that supports 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.

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

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.

jvperrin
  • 3,368
  • 1
  • 23
  • 33
Airtower
  • 255
  • 1
  • 3
  • 10
  • possible duplicate of [How can I disable ARC for a single file in a project?](http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project) – matt Mar 14 '14 at 18:38
  • Suspect the [similar Pillow compile fix might help](http://garmoncheg.blogspot.com/2014/04/pillow-compile-error-clang-wno.html) – garmoncheg Apr 28 '14 at 09:06

5 Answers5

12

There is no such thing as -fno-obj-arc. This never was working correctly; you just weren't seeing the warnings. The correct form is -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-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?). 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 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.

Community
  • 1
  • 1
matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Where would i possibly put -fno-obj-arc in my code? What i mean is, all my code conforms to Xcode and i see no errors. The error is in clang, as shown above in the error i am getting. – Airtower Mar 14 '14 at 03:37
  • 5
    No. Clang is reporting your error. You have put this for some of your files, probably in the build phases of your target. - it is your project. It did not fall from heaven. You wrote it. You made an error. Fix it. – matt Mar 14 '14 at 03:49
  • @user1311069 The simplest solution is probably to use the Xcode 5.0.2 clang, as I explain here: http://stackoverflow.com/a/22467108/341994 – matt Mar 20 '14 at 17:12
6

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

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

daroo
  • 342
  • 4
  • 8
  • 15
    ```export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"``` – msc Apr 26 '14 at 18:24
  • And if you're using `sudo`, `sudo ARCHFLAGS=-Wno-error=nused-command-line-argument-hard-error-in-future your command here` – Ian May 16 '14 at 20:36
  • 1
    @msc, your answer should be *the* answer. I've returned to this site a dozen or so times to use that command. – Naijaba May 29 '14 at 02:45
2

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

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.

Airtower
  • 255
  • 1
  • 3
  • 10
  • Thanks for posting your answer! Please note that you should post the essential parts of the answer here, on this site, or your post risks being deleted [See the FAQ where it mentions answers that are 'barely more than a link'.](http://stackoverflow.com/faq#deletion) You may still include the link if you wish, but only as a 'reference'. The answer should stand on its own without needing the link. – Taryn Mar 18 '14 at 11:37
  • 3
    Well, also this answer describes the situation incorrectly. What I provided was not merely "a small bit of help". The OP kept insisting that clang itself was in error and that `-fno-obj-arc` was something that _it_ was saying. My answer, plus repeated comments, were needed to get the OP to understand that clang was merely _reporting_ the error, which was in the project itself. Moreover, my comments did explain where the error was likely to be found. – matt Mar 18 '14 at 16:47
2
export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
msc
  • 3,780
  • 1
  • 22
  • 27
0

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

Juraj Antas
  • 3,059
  • 27
  • 37