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?
Asked
Active
Viewed 3.9k times
4 Answers
30
Add the compiler flags under your Project -> Target -> Build Phases, just separate the flags by a space.

danielbeard
- 9,120
- 3
- 44
- 58
-
2If 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 :
- Select the "Build Phases" tab
- Unfold "Compile sources"
- Search for your specific file
- 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
- Select blue project file
- Select "Build phases".
- Disclose "Compile Sources".
- Double click on file that you want to add flags.
- Then set flags separated by space.

Andrey M.
- 3,021
- 29
- 42