XCode 4 - 发布模式标志、构建标志、链接标志 [英] XCode 4 - Release Mode Flags, Build Flags, Link Flags

查看:31
本文介绍了XCode 4 - 发布模式标志、构建标志、链接标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 MAC OS X 10.8 上使用 XCode 4.6.

I'm working with XCode 4.6 on MAC OS X 10.8.

我是这个 IDE 和平台的新手.我有一个我编译的项目,优化被 XCode 关闭.

I'm new to this IDE and platform. I have a project I compile and optimizations are turned off by XCode.

我是否设置了发布方案并不重要.

It doesn't matter if I set Release Scheme.

我在名为无法使用 XCode 4.5 禁用调试器",它与标志 '-O0' 和 '-Os' 有关.我知道某些标志设置了调试模式",这意味着没有进行优化,代码生成了更多数据来帮助调试.我只是在 XCode 中找不到控制此行为的单个参数(如 VS 中的/Mtd).

I saw at the thread named "Cannot Disable Debugger with XCode 4.5" that it has to do with the flags '-O0' and '-Os'. I know that some flag set "Debugging Mode" which means no optimization is done and more data is generated by the code to help debugging. I just can't find the single parameter which controls this behavior in XCode (Like /Mtd in VS).

XCode 选项中的哪个参数控制这个参数?

Which parameter in the XCode options controls this parameter?

此外,在 VS 中很容易将构建参数视为命令行(在选项下,链接器和构建).我在哪里可以在 XCode 中看到它?

Moreover, In VS it is easy to see the build parameters as a command line (Under options, both Linker, and Build). Where can I see that in XCode?

谢谢.

推荐答案

所有编译器和链接器标志都可以在项目或目标的构建设置"中找到(目标可以覆盖其项目的设置).要到达那里,请选择项目文件,然后选择您当前的目标,然后转到构建设置".选择顶部的全部"和级别"以显示所有可用选项及其设置位置(项目或目标 -- 最左边的获胜).

All the compiler and linker flags can be found within a project's or a target's "Build Settings" (targets can overwrite their projects' settings). To get there, select the project file, then select your current target, and go to "Build Settings". Select "All" and "Levels" at the top to display all available options and where they are set (project or target -- left-most wins).

选项被分组,例如链接器选项和编译器选项,其中大部分是指标志.Xcode 显示描述性名称而不是完整的标志名称.要查看后者,请选择感兴趣的行并在右侧面板(实用工具"面板)中选择快速帮助检查器".您似乎在寻找的标志在 Xcode 中称为优化级别".

The options are grouped, e.g., linker options and compiler options, and most of them refer to flags. Xcode shows a descriptive name rather than the full flag name. To see the latter, select the line of interest and select the "Quick Help Inspector" in the right panel ("Utilities" panel). The flag you seem to look for is called "Optimization Level" in Xcode.

您可以设置每个选项的值,Xcode 可能会在原始值旁边显示一些元信息,例如,-Os 的最快,最小"或 -的无"-O0.您可以为每个配置(默认情况下,发布和调试)独立设置所有选项.实际使用哪种配置取决于您的构建操作.如果你建立 &运行,默认使用Debug.如果您归档应用程序,则默认使用 Release.但是,您可以通过编辑方案来更改其中的大部分内容.

You can set each option's value, and Xcode may display some meta information next to the raw value, e.g., "Fastest, Smallest" for -Os, or "None" for -O0. You can set all options for each configuration (by default, Release and Debug) independently. Which configuration is actually used depends on your build action. If you build & run, Debug is used by default. If you archive an application, Release is used by default. However, you can change most of that by editing the schemes.

更新:要了解发布和调试配置之间的差异,请查看给定目标的构建设置".如果选项的值在两种配置(或您可能拥有的任何其他配置)中不同,则选项名称前面会有一个箭头,指示不同的值.例如,采用仅构建活动架构"设置.在调试模式下,它假定您为特定的测试设备构建,因此也不需要包含为其他平台生成的代码.但是,如果您构建应用以进行分发,您希望构建一个包含所有目标设备/硬件架构代码的应用.

Update: To get an idea of the differences between the Release and Debug configuration, look at the "Build Settings" of a given target. If an option's value differs in both configurations (or any other configuration you may have), there's an arrow in front of the option's name which indicates the differing values. E.g., take the "Build Active Architecures Only" setting. In debug mode, it assumes you build for a particular testing device so there's no need to include code generated for other platforms as well. However, if you build your app for distribution, you want to build one app that includes code for all target devices/hardware architectures.

要研究的其他选项:-Debug Information Format:调试信息(崩溃报告)的存储方式.在发布模式下,这被设置为DWARF with dSym",这意味着您的崩溃报告是加密的,因此其他人无法从中获取有意义的信息(符号名称).

Other options to look into: -Debug Information Format: The way debug information (crash reports) are stored. In Release mode, this is set to "DWARF with dSym", which means that your crash reports are encrypted so no one else can get meaningful information (symbol names) out of them.

-复制期间去除调试符号

-Strip Debug Symbols During Copy

-优化级别,如上所述

-预处理器宏:这允许您使代码(静态)依赖于构建配置,例如,仅在调试模式下登录

-Preprocessor Macros: This allows you to make your code (statically) dependent on the build configuration, e.g., to log only in Debug mode

Xcode 在上述快速帮助检查器"中提供了有关所有这些选项的更多(并且可能更准确)的信息,只需选择任何选项即可.

Xcode provides more (and probably more accurate) information on all these options in the above-mentioned "Quick Help Inspector", just select any option.

根据我的经验,尽管进行了优化,但发布版本通常更快(即,它们的构建速度更快)并且尺寸肯定更小.

From my experience, despite the optimisation, Release builds are often faster (i.e., they build faster) and definitely smaller in size.

这篇关于XCode 4 - 发布模式标志、构建标志、链接标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆