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

推荐订阅源

A
About on SuperTechFans
D
DataBreaches.Net
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
Recent Announcements
Recent Announcements
The Register - Security
The Register - Security
S
Secure Thoughts
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
V2EX - 技术
V2EX - 技术
腾讯CDC
GbyAI
GbyAI
G
Google Developers Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
Schneier on Security
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
Jina AI
Jina AI
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
Help Net Security
Help Net Security
K
Kaspersky official blog
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
AI
AI
MongoDB | Blog
MongoDB | Blog
Scott Helme
Scott Helme
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
H
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
S
Security Affairs
TaoSecurity Blog
TaoSecurity Blog
The GitHub Blog
The GitHub Blog
Hacker News: Ask HN
Hacker News: Ask HN
Martin Fowler
Martin Fowler
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI

博客园 - chaoguo1234

如何自定义 UIScrollView 的减速系数 Plist 二进制格式 UIImageView 设置图片不生效的原因排查 Any metadata 的内存布局 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