学习和理解 Xcode 构建系统
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5490048/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Learning and Understanding the Xcode Build System
提问by gks
Alright, I'm curious about the build process with Xcode. Setting up multiple Targets, how to automate versioning and generally understanding the system so I can manipulate it to do what I want.
好吧,我对 Xcode 的构建过程很好奇。设置多个目标、如何自动化版本控制以及大致了解系统,以便我可以操纵它来做我想做的事。
Does anyone have any books or can point me to some documentation somewhere so that I can figure all of this out?
有没有人有任何书或可以将我指向某处的一些文档,以便我可以弄清楚所有这些?
Thanks a ton.
万分感谢。
Another thing, if anyone actually sees this since changing it.
另一件事,如果有人在更改它后确实看到了这一点。
But any books anyone is aware of that will focus on Xcode 4? There's Xcode 3 Unleashed but I'd be real curious if there are any books that focus heavily on Xcode 4.
但是任何人都知道有哪些书会关注 Xcode 4?有 Xcode 3 Unleashed 但我真的很好奇是否有任何关于 Xcode 4 的书籍。
回答by the_mandrill
One thing that is really essential for consistent, reproducible, automatable builds is knowledge of the xcodebuild
command. Sadly I can't find any official docs on it apart from the manpage (type man xcodebuild
). There's a useful guide to automating iphone builds herethat includes building with xcodebuild
and versioning with agvtool
. This is just as relevant to general building of Mac apps.
对于一致的、可重复的、可自动化的构建来说,真正必不可少的一件事是了解xcodebuild
命令。遗憾的是,除了联机帮助页(类型man xcodebuild
)之外,我找不到任何官方文档。有到自动化iphone建立一个有用的指南这里包括与建设xcodebuild
,并与版本agvtool
。这与 Mac 应用程序的一般构建同样相关。
Generally building with xcodebuild is very simple:
通常使用 xcodebuild 构建非常简单:
cd project_dir
xcodebuild -project myproject.xcodeproj -configuration Release ARCHS="x86_64 i386" build
Once you can build from a script like this it's very easy to slot into an automated build system.
一旦您可以从这样的脚本构建,就很容易插入自动构建系统。
回答by yoAlex5
When you compile a source file, the next steps are run.
编译源文件时,将运行后续步骤。
Preprocessing
:- Replace macros
- Splits
.h
and.m
.
In Xcode, you can look at the preprocessor output of
.m
file by selectingselect .m file -> Product -> Perform Action -> Preprocess
Compiling
- translates a low-level intermediate code.
Often you can see this file when debug a code that you are not owned. Xcode allows you yo review the output.select .m file -> Product -> Perform Action -> Assemble
Assembling
(produce.o
) - translates code into object file (.o
file)[Mach-O]In Xcode, you'll find these object files inside the<product_name>.build/Objects-normal
folder inside the derived data directory.Static Linking
(produce.app
,.a
,.framework
...) - It is a part of static linker that has to resolve symbols between object files and libraries/frameworks. This process produce a merged executable file which can contain additional resources and dynamic binaryDynamic linking
- linking in a loading or runtime. This process can generate errors during binary execution
Preprocessing
:- 替换宏
- 分裂
.h
和.m
。
在 Xcode 中,您可以
.m
通过选择查看文件的预处理器输出select .m file -> Product -> Perform Action -> Preprocess
Compiling
- 翻译低级中间代码。
通常,您可以在调试不属于您的代码时看到此文件。Xcode 允许您查看输出。select .m file -> Product -> Perform Action -> Assemble
Assembling
(produce.o
) - 将代码转换为目标文件 (.o
file) [Mach-O]在 Xcode 中,您将<product_name>.build/Objects-normal
在派生数据目录内的文件夹中找到这些目标文件。Static Linking
(produce.app
,.a
,.framework
...) - 它是静态链接器的一部分,必须解析目标文件和库/框架之间的符号。这个过程产生一个合并的可执行文件,它可以包含额外的资源和动态二进制文件Dynamic linking
- 在加载或运行时链接。此过程可能会在二进制执行期间产生错误
Take a look at example of static dynamic frameworks
Also you can use Xcode Report Navigator
to learn more about build process
您也可以使用 XcodeReport Navigator
来了解有关构建过程的更多信息