views:

297

answers:

2

I've been tasked to work on a project that has some confusing attributes.

The project is of the nature that it won't compile for the iPhone Simulator And the iPhone Device with the same compile settings. I think it has to do with needing to be specifically compiled for x86 or arm6/7 depending on the target platform.

So the project's build settings, when viewed in Xcode's Build Settings view doesn't enable me to set specific compiler flags per specific files. However, the previous developer that worked on this project has somehow declared the line:

CE7FEB5710F09234004DE356 /* MyFile.m in Sources */ = {isa = PBXBuildFile; fileRef = CE7FEB5510F09234004DE356 /* MyFile.m */; settings = {COMPILER_FLAGS = "-fasm-blocks -marm -mfpu=neon"; }; };

Is there any way to do this without editing the project file by hand? I know that editing the project file can result in breaking it completely, so I'd rather not do that, as I obviously don't know as much as the previous developer.

So to clarify, the question is:

The build fails when compiling for simulator unless I remove the -fasm-blocks flag. The build fails when compiling for device unless I add the -fasm-blocks flag. Is there a way to set this flag per file without editing the project file by hand?

+2  A: 

You can define additional compiler flags for individual source files as follows:

  • first select the target you are going to build
  • right click on the source file
  • select "Get Info"
  • click on the "Build" tab
  • define your additional compiler flags

However it sounds like a better solution in your case is just to duplicate the target and have two targets - one for an actual device and one for the simulator. Inherit common build settings from the project level and just tweak the per-target build settings as necessary.

Paul R
Thanks!So this may answer the other question I was going to ask, which was how could I automate the compile flag?I could set up a run script phase that runs before the compile sources phase and set the value of a compiler flags environment variable, based on the output of the target platform environment variable.The compiler flat only needs to be set on the one particular file, so I think it may be overkill to setup two targets and create a project wide compiler flag...
Jasarien
+1  A: 

Call GetInfo for the specific file, you can set the Build settings there for this file. See also the XCode Project Management Guide about this.

Jens