惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - chaoguo1234

Plist 二进制格式 UIImageView 设置图片不生效的原因排查 Any metadata 的内存布局 - chaoguo1234 Mach-O 文件结构 Block Copy 的内存布局详解 __block 变量内存布局详解 Block 内存布局详解 WebKit Insie: WebKit 调试(二) NSMutableDictionary 的内存布局 NSDictionary 内存布局 WebKit Inside: GPU 进程调试 WebKit Inside: 渲染树 WebKit Inside: px 与 pt WebKit Inside: CSS 的匹配原理 dyld: 神秘的 __dso_handle 一文搞懂 ARM 64 系列: ADD(立即数版) 一文搞懂 ARM 64: AUTIBSP 一文搞懂 ARM 64 系列: PACISB XCode 编译 PAG 源码 一文搞懂 ARM 64 系列: 一文搞懂 ARM 64 系列: 函数调用传参与返回值 一文搞懂 ARM 64 系列: 寄存器
XNU Inside: iOS 模拟器
chaoguo1234 · 2025-12-06 · via 博客园 - chaoguo1234

1 Simulator.app

iOS模拟器App位于XCode中:

/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app

Simulator.app只是定义了模拟器的UI

想要完整的运行模拟器,还需要很多其他组件。

2 CoreSimulator & SimulatorKit

CoreSimulator是一个Framework,它位于:

/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator

这个Framework会启动一个XPC服务:com.apple.CoreSimulator.CoreSimulatorService

这个XPC服务统管Mac上的所有模拟器。

当创建一个新的模拟器时,就是由这个XPC服务创建对应的模拟器设备文件和运行时。

CoreSimlator.framework还依赖于SimulatorKit.framework:

/Applications/Xcode.app/Contents/Developer/Library/PrivateFrameworks/SimulatorKit.framework/Versions/A/SimulatorKit

3 模拟器设备文件

有了模拟器设备文件,在XCode的设备列表中,才会显示出有哪些模拟器可用:

image

模拟器设备文件定义在:

/Library/Developer/CoreSimulator/Profiles/DeviceTypes

这个目录下的每一个.simdevicetpye文件定义了一个模拟器设备。

每一个.simdevicetype文件都是一个bundle文件。

这个bundle文件中最重要的是位于Resources文件夹下的2plist文件:

profile.plist定义了这个模拟器的特征,比如屏幕大小。

capabilities.plist定义了这个模拟器支持的功能。

4 模拟器运行时

iOS模拟器要运行,还需要对应的运行时支持。

运行时文件定义在:

/Library/Developer/CoreSimulator/Volumes/iOS_23A343/Library/Developer/CoreSimulator/Profiles/Runtimes

这个目录下的每一个.simruntime文件定义对应模拟器的运行时。

每一个simruntime文件是一个bundle文件。

这个bundle文件中最重要的是位于Resources文件夹下的plist文件:profile.plist

profile.plist里定义这个模拟器支持的iOS系统版本,以及依赖的服务。

5 模拟器的启动

模拟器由launchd_sim启动,它位于模拟器运行时下:

/Library/Developer/CoreSimulator/Volumes/iOS_23A343/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 26.0.simruntime/Contents/Resources/RuntimeRoot/sbin/launchd_sim

launchd_sim会依次将模拟器所需要的服务启动起来。

这些依赖的服务都定义在com.apple.CoreSimulator.bridge.plist中,它位于:

/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/Resources/Platforms/iphoneos/Library/LaunchDaemons/com.apple.CoreSimulator.bridge.plist

模拟器启动完成之后,它的根文件系统挂载在RuntimeRoot目录:

/Library/Developer/CoreSimulator/Volumes/iOS_23A343/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 26.0.simruntime/Contents/Resources/RuntimeRoot

它的数据部分挂载如下目录:

~/Library/Developer/CoreSimulator/Devices/UUID

当在模拟器环境下执行

po NSHomeDirectory()

会得到如下输出:

po NSHomeDirectory()
/Users/huchao03/Library/Developer/CoreSimulator/Devices/4115D910-245F-425D-8E82-EAE2E238147A/data/Containers/Data/Application/
E6BDDBF1-447D-4D37-98F8-E61F48080A48

当模拟器需要访问相应的文件系统,CoreSimulatorBridge就会拦截这个请求,将其代理到对应目录上。

CoreSimulatorBridge位于:

/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/Resources/Platforms/iphoneos/usr/libexec/CoreSimulatorBridge

6 dyld_sim

模拟器运行时,加载链接动态库时,不是使用的dyld,而是dyld_sim

dyld_sim位于RuntimeRoot中:

/Library/Developer/CoreSimulator/Volumes/iOS_23A343/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 26.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim

7 simctl

simctl命令行工具可以运行、杀死模拟器。

simctlXCode自带的工具,运行是需要使用xcrun命令:

xcrun simctl list

simctl位于:

/Applications/Xcode.app/Contents/Developer/usr/bin/simctl