14

I would like to add two compiler flags, one for ARC (-fno-objc-arc) and one for warning (-w). Anybody know how to add two compiler flags in the Xcode build phase for a particular file?

4 Answers 4

30

Add the compiler flags under your Project -> Target -> Build Phases, just separate the flags by a space.

Imgur

Sign up to request clarification or add additional context in comments.

5 Comments

If he does it in the build settings, it will apply to all files. He wants to do it for a particular file.
Sorry, meant build phases, my image reflects this. I have also updated my answer.
Hello, what to do if the file that I want to suppress is a header file?
I need flags: "-I/usr/local/opt/libgcrypt/include -I/usr/local/opt/libgpg-error/include -L/usr/local/opt/libgcrypt/lib -lgcrypt -L/usr/local/opt/libgpg-error/lib -lgpg-error" but these files can't be found in the finder window that comes up when I add a compile source... any ideas? I just want to paste these flags.
@GregoryFenn go to Build Settings > Linking > Other Linker Flags, and put those there.
7

In Xcode, clic on your project file to see the pane with your target(s) and then :

  1. Select the "Build Phases" tab
  2. Unfold "Compile sources"
  3. Search for your specific file
  4. Set your compiler flags on this particular file by double-clik on this column.

Hope this helps

Comments

1
  1. Select blue project file
  2. Select "Build phases".
  3. Disclose "Compile Sources".
  4. Double click on file that you want to add flags.
  5. Then set flags separated by space.

Comments

0

Select your project in the project navigator in the left-hand panel, select your target, then select Build Phases. Expand Compile Sources and double-click the file you want to set the compiler flag for. Repeat for each target you want the changes to apply to.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.