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

发布于 2024-08-30 22:20:02 字数 672 浏览 3 评论 0原文

我的任务是从事一个具有一些令人困惑的属性的项目。

该项目的性质是,它不会为具有相同编译设置的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清泪尽 2024-09-06 22:20:02

Joshua Nozzi 的这篇博客文章解释了如何执行此操作在 Xcode 4 中,他说:

...在项目导航器中选择您的项目,选择相关目标(您可能只有一个),然后选择“构建阶段”选项卡。展开编译源阶段和中提琴!编译器标志列可让您为该目标设置每个文件的标志。

This blog post by Joshua Nozzi explains how to do this in Xcode 4, where he says:

... select your project in the Project Navigator, select the relevant target (you may have only one), then select the Build Phases tab. Expand the Compile Sources phase and viola! A Compiler Flags column lets you set each file’s flags for that target.

无名指的心愿 2024-09-06 22:20:02

您可以为各个源文件定义附加编译器标志,如下所示:

  • 首先选择要构建的目标,
  • 右键单击源文件
  • ,选择“获取信息”,
  • 单击“构建”选项卡,
  • 定义附加编译器标志

,但这听起来像在您的情况下,更好的解决方案就是复制目标并有两个目标 - 一个用于实际设备,一个用于模拟器。从项目级别继承常见的构建设置,并根据需要调整每个目标的构建设置。

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.

遗失的美好 2024-09-06 22:20:02

为特定文件调用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文