Skip to main content

hinge:控制可折叠 iPhone 模拟器的铰链

控制可折叠 iPhone 模拟器的铰链角度,以测试应用对显示变化的反应。

来源信息

仓库
artemnovichkov/hinge
最近来源活动
2026年10月21日 13:21
检测到的 SKILL.md 语言
英语
星标
15
Forks
1

用途

当需要折叠、展开、半开或动画演示运行中的可折叠模拟器时使用。

必要前提

macOS 和 Xcode 27.1+ 以及一个已启动的可折叠模拟器。

操作说明

确保可折叠模拟器已启动,然后运行带有角度或动作的 hinge 命令。

限制

仅适用于模拟器,不支持物理设备。

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

文件资源管理器
3 个文件

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
hinge
description
Control the hinge (fold) angle of a foldable iPhone Simulator such as iPhone Duo. Use when you need to fold, unfold, half-open, or animate the fold of a running simulator, read its current hinge angle, or test how an app reacts to hinge and display changes.
# hinge Set and read the hinge angle of a booted foldable iPhone Simulator from the command line. It posts the same HID event as the hidden hinge slider in Xcode's Device Hub (hold Option). Run the bundled script at `scripts/hinge`, relative to this skill's directory. If `hinge` is on `PATH`, you can use that instead. ## Commands ```bash scripts/hinge 120 # set angle: 0 = closed, 180 = flat scripts/hinge open # 180° scripts/hinge close # 0° scripts/hinge half # 90° scripts/hinge sweep 180 0 2 # animate from 180° to 0° over 2 seconds scripts/hinge get # print current angle, e.g. 130.0 scripts/hinge posture # angle, orientation, and which integrated display is active scripts/hinge rotate left # rotate 90°, like Device Hub's Controls > Rotate Left; prints the new orientation scripts/hinge rotate right scripts/hinge orient landscape-left # portrait, landscape-left, landscape-right, or portrait-upside-down scripts/hinge orientation # print current orientation, e.g. landscape-left scripts/hinge -d "iPhone Duo" 90 # target a simulator by name or UDID (default: booted) scripts/hinge -t 0 90 # set without waiting for the angle to be confirmed ``` `open`, `close` and `half` also accept `unfolded`/`flat`, `closed`/`folded` and `half-open`. ## Workflow 1. Make sure a foldable simulator is booted: `xcrun simctl list devices booted`. 2. Set the angle. The command returns once the simulator reports the new angle, so a non-zero exit means the fold did not happen — don't poll `get` to check it. 3. Wait about half a second before you screenshot or read the UI: the display switch takes 1-2.5 s after the angle changes. 4. `scripts/hinge posture` tells which display hosts the UI (`active`) after a fold. 5. Screenshots: `xcrun simctl io booted screenshot out.png`. For the outer display, add `--display=1`. ## Notes - Simulator only. It does not work on physical devices. - The first run compiles a tiny helper with Xcode's clang, caching it under `~/.cache/hinge`. It takes a few seconds. - A `sweep` runs at 60 Hz in one process. For a smooth animation, use it instead of many `set` calls. It does not confirm the final angle. - Only 0° and 180° reliably switch the active display. At angles in between, the result depends on the path the hinge took, so a slow `sweep` can keep the previous display active until the end. To be sure a display switched, set 0° or 180° and check `posture`. - Angles outside 0-180 are rejected. A simulator without a hinge fails with "this simulator reports no hinge". - `orient`, `orientation` and `rotate` use device orientations (the `devicectl` names), not interface orientations: a device in `landscape-right` shows a `landscape-left` interface. - Orientation on a foldable follows only Device Hub's own event; `xcrun devicectl device orientation set` reports success there but is reverted. `rotate`/`orient` send Device Hub's event and fall back to `devicectl` on simulators that ignore it. - This uses a private, undocumented protocol. It was verified with Xcode 27.1 and iOS 27.1 and may break in other versions. If setting an angle fails with "the hinge angle did not reach ...", report that the protocol has likely changed.
在 GitHub 查看