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?

Alex Zavatone
  • 4,106
  • 36
  • 54
AAV
  • 3,785
  • 8
  • 32
  • 59

4 Answers4

30

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

Imgur

danielbeard
  • 9,120
  • 3
  • 44
  • 58
  • 2
    If he does it in the build settings, it will apply to all files. He wants to do it for a particular file. – Jim Sep 05 '12 at 23:48
  • Sorry, meant build phases, my image reflects this. I have also updated my answer. – danielbeard Sep 05 '12 at 23:51
  • Hello, what to do if the file that I want to suppress is a header file? – Georgi Boyadzhiev Jun 30 '16 at 12:06
  • 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. – Gregory Fenn Feb 17 '19 at 16:35
  • 1
    @GregoryFenn go to Build Settings > Linking > Other Linker Flags, and put those there. – danielbeard Feb 28 '19 at 00:46
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

iGranDav
  • 2,450
  • 1
  • 21
  • 25
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.

Jim
  • 72,985
  • 14
  • 101
  • 108
0
  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.
Andrey M.
  • 3,021
  • 29
  • 42