Xcode中特定文件的特定编译器标志

Xcode中特定文件的特定编译器标志

本文介绍了Xcode中特定文件的特定编译器标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是处理一个有一些令人困惑的属性的项目。

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

该项目具有不会为iPhone模拟器编译的性质和iPhone设备具有相同的编译设置。我认为这需要针对x86或arm6 / 7进行专门编译,具体取决于目标平台。

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.

所以在Xcode的Build中查看项目的构建设置设置视图不允许我为每个特定文件设置特定的编译器标志。但是,以前开发过这个项目的开发人员已经以某种方式声明了这一行:

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.

所以要澄清,问题是:

编译模拟器时构建失败,除非我删除 -fasm-blocks 标志。编译设备时构建失败,除非我添加 -fasm-blocks 标志。有没有办法在不编辑项目文件的情况下为每个文件设置此标志?

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?

推荐答案

您可以为其定义其他编译器标志个别源文件如下:

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


  • 首先选择您要构建的目标

  • 右键单击在源文件上

  • 选择获取信息

  • 单击构建选项卡

  • define你的额外编译器标志

  • 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.

这篇关于Xcode中特定文件的特定编译器标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 17:12