展示HN:我们为Maestro添加了iOS真实设备支持
自2023年1月以来,iOS真实设备支持一直是Maestro用户最迫切的需求。近三年来,GitHub上有大量问题和评论在请求这一功能。
我们在工作中需要这个功能,因此我们开发了它并提交了PR #2856。但Maestro团队表示,官方支持要到明年才能推出——没有明确的时间表。
我们不希望团队们再等待,因此我们打包了一个独立工具,今天就可以使用。
工作原理:
- maestro-ios-device会将XCTest运行器构建并部署到你的真实iPhone上。
- 端口转发将localhost:6001桥接到设备:22087。
- 你现有的Maestro YAML文件无需更改即可运行。
额外功能:我们还解锁了在多个真实设备上并行执行的能力。Maestro之前有硬编码的端口限制——现在你可以在设备1上使用:6001,在设备2上使用:6002同时运行。
限制(苹果限制):
- clearState通过重新安装应用程序工作(而不是simctl)。
- setLocation需要额外的设置。
- 不支持addMedia。
安装:
```bash
curl -fsSL https://raw.githubusercontent.com/devicelab-dev/maestro-ios-device/main/setup.sh | bash
```
仓库: [https://github.com/devicelab-dev/maestro-ios-device](https://github.com/devicelab-dev/maestro-ios-device)
PR: [https://github.com/mobile-dev-inc/Maestro/pull/2856](https://github.com/mobile-dev-inc/Maestro/pull/2856)
在iOS 18.x和26.x上与Maestro 2.0.9/2.0.10进行了测试。
这不是官方版本——当Maestro推出原生支持时,请使用官方版本。欢迎就实现细节提问。
查看原文
iOS real device support has been Maestro's most requested feature since January 2023. Almost 3 years of GitHub issues and comments asking for the same thing.<p>We needed it for our work, so we built it and submitted PR #2856. But the Maestro team said official support won't land until next year — no committed timeline.<p>We didn't want teams to wait, so we packaged a standalone tool that works today.<p>How it works:
- maestro-ios-device builds and deploys the XCTest runner to your physical iPhone
- Port forwarding bridges localhost:6001 → device:22087
- Your existing Maestro YAML runs unchanged<p>Bonus: We also unlocked parallel execution on multiple real devices. Maestro had a hardcoded port limitation — now you can run on device 1 at :6001 and device 2 at :6002 simultaneously.<p>Limitations (Apple restrictions):
- clearState works via app reinstall (not simctl)
- setLocation requires additional setup
- addMedia not supported<p>Install:
curl -fsSL <a href="https://raw.githubusercontent.com/devicelab-dev/maestro-ios-device/main/setup.sh" rel="nofollow">https://raw.githubusercontent.com/devicelab-dev/maestro-ios-...</a> | bash<p>Repo: <a href="https://github.com/devicelab-dev/maestro-ios-device" rel="nofollow">https://github.com/devicelab-dev/maestro-ios-device</a>
PR: <a href="https://github.com/mobile-dev-inc/Maestro/pull/2856" rel="nofollow">https://github.com/mobile-dev-inc/Maestro/pull/2856</a><p>Tested on iOS 18.x and 26.x with Maestro 2.0.9/2.0.10.<p>This is unofficial — when Maestro ships native support, use that instead. Happy to answer questions about the implementation.