> For the complete documentation index, see [llms.txt](https://ryukiedev.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ryukiedev.gitbook.io/wiki/ios/za-xiang/yuan-dai-ma-dao-ipa.md).

# 06.源代码到IPA

* 进行编译
* 生成DSYM文件
  * 储存了16进制的函数地址映射
  * 崩溃日志中的地址通过此文件由地址映射到具体的函数位置

## 1. 编译

> Clang + LLVM
>
> > 把源代码转换为更为地址的LLVM IR(Intermedia Represention) LLVM根据上面转换的IR进行二进制文件的产出

* 预处理
  * 处理源文件中的宏定义,将代码中的宏用对应的定义的具体内容进行替换
* 便已生成IR(中间代码)
* 汇编器生成汇编代码
* 生成机器码
* 链接
* 生成Image,也就是最后的可执行文件

## 2. 每次Command+B发生的事情(基于CocoaPod时)

* 编译信息写入辅助文件,创建.app文件
* 处理文件打包信息
* 执行CocoaPod编译前脚本,checkPods Manifest.lock
* 编译.m文件,使用CompileC和clang命令
* 链接需要的Framework
* 编译xib
* 拷贝xib,资源文件
* 编译ImageAssets
* 处理Info.plist
* 执行CocoaPod脚本
  * Run custom shell script 'Embed Pods Frameworks'
  * Run custom shell script 'Copy Pods Resources'
* 拷贝标准库
* 创建.app文件和签名

## 参考

> <https://www.jianshu.com/p/0df698478b39>
