如何打印“构建设置”列表在 Xcode 项目中?
备用标题
- Xcode 构建变量列表
- 打印 Xcode 构建设置列表
- Clang 环境变量
- Xcode 环境变量的规范列表
是否存在可在构建规则中使用的 Xcode 环境变量规范列表/em> 等等?
Alternate Titles
- List of Xcode build variables
- Print a list of Xcode Build Settings
- Clang Environment Variables
- Canonical list of Xcode Environment Variables
Is there a Canonical list of Xcode Environment Variables that can be used in Build Rules etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您想使用代码在运行时中读取/检查您的
目标构建设置
,方法如下:1) 添加
运行脚本
:它将把
Target Build Settings
文件复制到您的Main Bundle
中(将被称为BuildSetting.pbxproj
)。2)您现在可以随时用代码检查该文件的内容:
In case you would like to read/check your
Target Build Settings
in runtime using code, here is the way:1) Add a
Run Script
:It will copy the
Target Build Settings
file into yourMain Bundle
(will be calledBuildSetting.pbxproj
).2) You can now check the contents of that file at any time in code:
原答案
Original Answer
您还可以使用带有 -showBuildSettings 开关的 xcodebuild 命令从命令行获取此信息:
这会将如上所示的列表转储到标准输出。
You can also get this information from the command line using the xcodebuild command with the -showBuildSettings switch:
This will dump a list like the one shown above to the standard output.
尽管@dunedin15的出色答案在很多场合都为我提供了很好的帮助,但对于某些边缘情况,它可能会给出不准确的结果, 例如在检查存档构建的静态库的构建设置时。
作为替代方案,运行脚本构建阶段可以轻松添加到任何目标,以在构建时“记录构建设置”:
将目标置于在“构建阶段”选项卡下选择问题:
/bin/bash
和导出
命令。结果是用于构建的当前环境变量的非常有用的列表:
Although @dunedin15's fantastic answer has served me well on a number of occasions, it can give inaccurate results for some edge-cases, such as when inspecting build settings of a static lib for an Archive build.
As an alternative, a Run Script Build Phase can be easily added to any target to “Log Build Settings” when it's built:
With the target in question selected, under the Build Phases tab:
/bin/bash
and the command toexport
.The result is this incredibly helpful listing of current environment variables used for building:
Apple 的“构建设置参考”文档,了解官方记录的内容(或 rjstelling 的答案显示,在构建脚本中使用 env 来查看 Xcode 实际传递给您的内容,
以防上述链接发生变化,Google 搜索:
“构建设置参考”站点:developer.apple.com
Apple's "Build Setting Reference" documentation for what's officially documented (or as rjstelling's answer shows, use env in a build script to see what Xcode actually passes you.
In case the above link changes, Google search for:
"build setting reference" site:developer.apple.com
上面已经回答了这个问题,但我想提出一个替代方案。
在项目或目标的“构建设置”中时,您可以转到“编辑器”菜单并从菜单中选择“显示设置名称”。这会将“构建设置”窗格中的所有选项更改为构建变量名称。菜单中的选项更改为
显示设置标题
,选择此选项可更改回原始视图。当您知道要在脚本中使用什么构建设置时,这会很方便,在菜单中切换设置名称,您就可以看到变量名称。
This has been answered above, but I wanted to suggest an alternative.
When in the Build Settings for you project or target, you can go to the Editor menu and select
Show Setting Names
from the menu. This will change all of the options in the Build Settings pane to the build variable names. The option in the menu changes toShow Setting Titles
, select this to change back to the original view.This can be handy when you know what build setting you want to use in a script, toggle the setting names in the menu and you can see the variable name.
在 Xcode 4 以及可能之前的版本中,在运行脚本构建阶段有一个选项“在构建阶段显示环境变量”。如果选择,这将在构建日志中显示在橄榄绿背景上。
In Xcode 4 and possibly before, in the run script build phase there is an option "Show enviroment variables in build phase". If selected this will show then on a olive green background in the build log.