Xcode 中特定文件的特定编译器标志
我的任务是从事一个具有一些令人困惑的属性的项目。
该项目的性质是,它不会为具有相同编译设置的 iPhone 模拟器和 iPhone 设备进行编译。我认为这与需要根据目标平台专门为 x86 或 arm6/7 进行编译有关。
因此,在 Xcode 的“构建设置”视图中查看项目的构建设置时,我无法为每个特定文件设置特定的编译器标志。然而,之前从事该项目的开发人员以某种方式声明了这一点:
CE7FEB5710F09234004DE356 /* MyFile.m in Sources */ = {isa = PBXBuildFile; fileRef = CE7FEB5510F09234004DE356 /* MyFile.m */; settings = {COMPILER_FLAGS = "-fasm-blocks -marm -mfpu=neon"; }; };
有没有办法在不手动编辑项目文件的情况下做到这一点?我知道编辑项目文件可能会导致它完全损坏,所以我宁愿不这样做,因为我显然不如以前的开发人员了解得那么多。
因此,为了澄清,问题是:
除非我删除 -fasm-blocks
标志,否则编译模拟器时构建会失败。除非添加 -fasm-blocks
标志,否则编译设备时构建会失败。有没有办法为每个文件设置此标志,而无需手动编辑项目文件?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Joshua Nozzi 的这篇博客文章解释了如何执行此操作在 Xcode 4 中,他说:
This blog post by Joshua Nozzi explains how to do this in Xcode 4, where he says:
您可以为各个源文件定义附加编译器标志,如下所示:
,但这听起来像在您的情况下,更好的解决方案就是复制目标并有两个目标 - 一个用于实际设备,一个用于模拟器。从项目级别继承常见的构建设置,并根据需要调整每个目标的构建设置。
You can define additional compiler flags for individual source files as follows:
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.
为特定文件调用 GetInfo,您可以在此处设置该文件的构建设置。另请参阅有关此内容的 Xcode 项目管理指南。
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.