# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ryukiedev.gitbook.io/wiki/ios/za-xiang/yuan-dai-ma-dao-ipa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
