diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..388bed1 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +# Lowest macOS the binaries run on, for every build (from source, CI, release). Rust's own default is 11.0 on Apple +# Silicon but 10.12 on Intel, and below 10.14.4 linking CoreMedia pulls in a Swift library through @rpath that isn't +# found at run time: an Intel build aborted at start. Ignored on other systems. +[env] +MACOSX_DEPLOYMENT_TARGET = "11.0" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2394b8c..37a514d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,8 @@ jobs: - name: Terminal menus (PTY) run: python3 tests/terminal.py --binary target/debug/iphone-control --test-dir target/debug/deps - # macOS(Apple Silicon)上能编译、测试通过;格式和平台无关,上面已经查过 + # macOS(Apple Silicon)上能编译、测试通过;格式和平台无关,上面已经查过。Intel Mac 的发布包在同一台机器上交叉编译, + # 这里也查一遍 x86_64 能编译(只 check,不链接、不跑测试) macos: needs: [changes] # changes 在 main 的推送上会跳过,这时照样跑 @@ -75,10 +76,12 @@ jobs: - uses: dtolnay/rust-toolchain@1.99.1 with: components: clippy + targets: x86_64-apple-darwin - uses: Swatinem/rust-cache@v2 # --all-features:默认不编的 debug-cmds(调试子命令)也要能编译 - run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings - run: cargo test --workspace --all-features --locked + - run: cargo clippy --workspace --all-targets --all-features --locked --target x86_64-apple-darwin -- -D warnings # macOS 上的终端菜单 PTY 回归。不在规则集的必过检查里:它靠两个进程之间的时间差模拟按键, # 忙的 macOS runner 上调度一卡就会误报(Linux 上同一个脚本在上面的 rust 里,仍是卡点)。 @@ -136,7 +139,7 @@ jobs: - name: Homebrew formula run: | shellcheck -s sh packaging/homebrew/formula.sh - ICTL_UPDATE_PUBLISHER="$GITHUB_REPOSITORY" sh packaging/homebrew/formula.sh v0.0.0 aaa bbb ccc > iphone-control.rb + ICTL_UPDATE_PUBLISHER="$GITHUB_REPOSITORY" sh packaging/homebrew/formula.sh v0.0.0 aaa bbb ccc ddd > iphone-control.rb grep -F "https://github.com/$GITHUB_REPOSITORY/releases/" iphone-control.rb ruby -c iphone-control.rb diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 21ab21c..e320d53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,6 @@ name: Release -# 推送 v* tag 时:Linux(x86_64、aarch64)和 macOS(Apple Silicon)的压缩包、Linux 的 .deb 及 sha256 附在 GitHub Release 上, +# 推送 v* tag 时:Linux(x86_64、aarch64)和 macOS(Apple Silicon、Intel)的压缩包、Linux 的 .deb 及 sha256 附在 GitHub Release 上, # 发布说明取自 CHANGELOG.md 和 CHANGELOG.zh-CN.md;稳定版按发布者配置签名并可选更新 tap。 on: push: @@ -114,7 +114,7 @@ jobs: echo "## 中文"; echo; echo "$zh"; echo # 已装的程序在「---」加「**Binaries / 二进制:**」处截掉页脚,按「## English」「## 中文」分语言,这三处别改 echo "---"; echo - echo "**Binaries / 二进制:** macOS \`macos-arm64\` (11+, Apple Silicon) · Linux \`linux-x86_64\`, \`linux-aarch64\` (glibc 2.34+) · \`.deb\` amd64, arm64 (Debian 12+, Ubuntu 22.04+)"; echo + echo "**Binaries / 二进制:** macOS \`macos-arm64\` (11+, Apple Silicon), \`macos-x86_64\` (11+, Intel) · Linux \`linux-x86_64\`, \`linux-aarch64\` (glibc 2.34+) · \`.deb\` amd64, arm64 (Debian 12+, Ubuntu 22.04+)"; echo if [[ "$GITHUB_REF_NAME" != *-* ]]; then echo "- **Script / 脚本:** \`curl -fsSL https://github.com/$GITHUB_REPOSITORY/releases/download/$GITHUB_REF_NAME/install.sh | sh\`" if [[ -n "$ICTL_UPDATE_TAP" ]]; then echo "- **Homebrew:** \`brew install $ICTL_UPDATE_TAP/iphone-control\`"; fi @@ -130,43 +130,66 @@ jobs: env: GH_TOKEN: ${{ github.token }} - # macOS(Apple Silicon)二进制,Release 建好后再传上去:GitHub 的 macOS runner 经常排队, - # 排不上时(15 分钟后被取消)不拖住镜像和 Linux 二进制,重跑这个任务就能补上。 - # 文件名里的 arm64 与 Mac 上 uname -m 一致。没有公证(要付费开发者账号):链接器自带 ad-hoc 签名能直接运行, + # macOS 二进制,Release 建好后再传上去:GitHub 的 macOS runner 经常排队, + # 排不上时(15 分钟后被取消)不拖住镜像和 Linux 二进制,重跑失败的任务就能补上。 + # Apple Silicon 和 Intel 都在同一种(Apple Silicon)runner 上编,Intel 的交叉编译(GitHub 的 Intel runner 越来越少), + # 最低系统都是 macOS 11。文件名里的 arm64、x86_64 与 Mac 上 uname -m 一致。 + # 没有公证(要付费开发者账号):arm64 的链接器自带 ad-hoc 签名,x86_64 的不带,这里补上,两个包一样; # 用终端 curl 下载不带隔离标记;浏览器下载的要去掉 com.apple.quarantine(见 macOS 指南) macos-binary: needs: release + strategy: + # 一个架构失败不取消另一个;两个都传上去之后才签名 + fail-fast: false + matrix: + include: + - target: aarch64-apple-darwin + arch: arm64 + - target: x86_64-apple-darwin + arch: x86_64 + # 最低系统 macOS 11 由 .cargo/config.toml 定,下面 Check 核对 runs-on: macos-latest steps: - uses: actions/checkout@v7 - uses: dtolnay/rust-toolchain@1.99.1 + with: + targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@v2 with: - key: release-aarch64-apple-darwin - - run: cargo build --release --locked -p iphone-control + key: release-${{ matrix.target }} + - run: cargo build --release --locked -p iphone-control --target ${{ matrix.target }} + - name: Ad-hoc signature (x86_64) + if: matrix.arch == 'x86_64' + run: codesign --sign - --force target/${{ matrix.target }}/release/iphone-control # 第三方 Rust 组件许可证清单(cargo-about,按 Cargo.lock 生成);白名单(packaging/licenses/about.toml)以外的许可证让发布失败 - uses: taiki-e/install-action@v2 with: tool: cargo-about@0.9.3 - run: cargo about generate --locked -m apps/iphone-control/Cargo.toml -c packaging/licenses/about.toml packaging/licenses/about.hbs -o THIRD_PARTY_LICENSES.html + # x86_64 的在 Rosetta 下跑一次;runner 上没装 Rosetta 时先装 - name: Check run: | - file target/release/iphone-control - codesign --verify --verbose target/release/iphone-control - target/release/iphone-control --version + bin=target/${{ matrix.target }}/release/iphone-control + file "$bin" | grep -q "${{ matrix.arch }}" + otool -l "$bin" | grep -A3 LC_BUILD_VERSION | grep -q "minos 11.0" + codesign --verify --verbose "$bin" + if [ "${{ matrix.arch }}" = x86_64 ] && ! arch -x86_64 /usr/bin/true 2>/dev/null; then + sudo softwareupdate --install-rosetta --agree-to-license + fi + arch -${{ matrix.arch }} "$bin" --version # 不带 deploy/(systemd 服务文件,Mac 上用不到) - name: Package run: | - name="iphone-control-${GITHUB_REF_NAME}-macos-arm64" + name="iphone-control-${GITHUB_REF_NAME}-macos-${{ matrix.arch }}" mkdir -p "dist/$name" - cp target/release/iphone-control LICENSE THIRD_PARTY.md README.md README.zh-CN.md CHANGELOG.md CHANGELOG.zh-CN.md "dist/$name/" + cp target/${{ matrix.target }}/release/iphone-control LICENSE THIRD_PARTY.md README.md README.zh-CN.md CHANGELOG.md CHANGELOG.zh-CN.md "dist/$name/" cp packaging/env.example "dist/$name/env.example" cp THIRD_PARTY_LICENSES.html "dist/$name/" tar -C dist -czf "dist/$name.tar.gz" "$name" (cd dist && shasum -a 256 "$name.tar.gz" > "$name.tar.gz.sha256") - uses: actions/upload-artifact@v7 with: - name: macos-archive + name: macos-archive-${{ matrix.arch }} path: dist/*.tar.gz* if-no-files-found: error @@ -180,10 +203,13 @@ jobs: - uses: actions/checkout@v7 - uses: actions/download-artifact@v8 with: - name: macos-archive + pattern: macos-archive-* path: dist + merge-multiple: true - name: Upload to the release - run: python3 packaging/release.py upload dist/*.tar.gz dist/*.tar.gz.sha256 + run: | + test "$(ls dist/*.tar.gz | wc -l)" -eq 2 + python3 packaging/release.py upload dist/*.tar.gz dist/*.tar.gz.sha256 env: GH_TOKEN: ${{ github.token }} @@ -235,24 +261,31 @@ jobs: contents: write steps: - uses: actions/checkout@v7 - - name: Download macOS archive + - name: Download macOS archives uses: actions/download-artifact@v8 with: - name: macos-archive + pattern: macos-archive-* path: built - - name: Compare published archive to build + merge-multiple: true + - name: Compare published archives to build env: GH_TOKEN: ${{ github.token }} run: | - gh release download "$GITHUB_REF_NAME" --pattern '*-macos-arm64.tar.gz' --dir dist - archive="iphone-control-$GITHUB_REF_NAME-macos-arm64.tar.gz" - cmp "built/$archive" "dist/$archive" - - name: Sign macOS manifest + gh release download "$GITHUB_REF_NAME" --pattern '*-macos-*.tar.gz' --dir dist + test "$(ls dist/*.tar.gz | wc -l)" -eq 2 + for arch in arm64 x86_64; do + archive="iphone-control-$GITHUB_REF_NAME-macos-$arch.tar.gz" + cmp "built/$archive" "dist/$archive" + done + - name: Sign macOS manifests env: ICTL_UPDATE_SIGNING_KEY: ${{ secrets.ICTL_UPDATE_SIGNING_KEY }} ICTL_UNATTENDED_TAG: ${{ vars.ICTL_UNATTENDED_TAG }} - run: python3 packaging/release.py sign dist macos-arm64 - - name: Publish signed macOS manifest + run: | + for target in macos-arm64 macos-x86_64; do + python3 packaging/release.py sign dist "$target" + done + - name: Publish signed macOS manifests env: GH_TOKEN: ${{ github.token }} run: python3 packaging/release.py upload dist/*.manifest.json* @@ -268,9 +301,10 @@ jobs: run: | gh release download "$GITHUB_REF_NAME" --pattern '*.manifest.json*' --dir signed mac=$(python3 packaging/release.py sha signed macos-arm64) + intel=$(python3 packaging/release.py sha signed macos-x86_64) x86=$(python3 packaging/release.py sha signed linux-x86_64) arm=$(python3 packaging/release.py sha signed linux-aarch64) - sh packaging/homebrew/formula.sh "$GITHUB_REF_NAME" "$mac" "$x86" "$arm" > iphone-control.rb + sh packaging/homebrew/formula.sh "$GITHUB_REF_NAME" "$mac" "$intel" "$x86" "$arm" > iphone-control.rb ruby -c iphone-control.rb env: GH_TOKEN: ${{ github.token }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d48301..a60402b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ What changed in each release, one line per change. Versions follow [Semantic Ver ## [Unreleased] +### New + +- Intel Macs (macOS 11+) get prebuilt binaries: install with the one-line script or Homebrew, upgrade with `iphone-control update` (#181). The package is cross-compiled and not yet tested on a real Intel Mac; reports are welcome. + ### Fixes - WebDriverAgent on the phone now listens on the phone itself only: other devices on the same Wi-Fi can no longer reach its port 8100 (the unauthenticated control API) or 9100 (the picture). After upgrading, a WDA an older version launched in the background is launched again once. diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 55e301d..1cf6614 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -6,6 +6,10 @@ ## [Unreleased] +### 新功能 + +- Intel 芯片的 Mac(macOS 11 及以上)有了预编译版本,可以用一行命令、Homebrew 安装,也能用 `iphone-control update` 升级(#181)。这个包是交叉编译的,还没在真正的 Intel Mac 上测过,遇到问题欢迎反馈。 + ### 修复 - 手机上的 WebDriverAgent 只在手机本机监听,同一 Wi-Fi 里的其他设备不能再访问它的 8100(没有认证的操作接口)和 9100(画面)端口。升级后,旧版本在后台启动的 WDA 会被重新启动一次。 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3156a62..aa33525 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -170,7 +170,7 @@ The user guide at [derrors.github.io/iphone-control](https://derrors.github.io/i 1. Move the *Unreleased* entries in [CHANGELOG.md](CHANGELOG.md) and [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md) under `## [x.y.z] - YYYY-MM-DD` and update the compare links at the bottom. Both files need the section — the release notes are built from the two (English, then Chinese) and the workflow fails if either is missing. Check the entries against [Changelog entries](#changelog-entries). 2. Set `version` in the root `Cargo.toml` (`[workspace.package]`) and run `cargo check --workspace` to update `Cargo.lock`. -3. Configure the publisher and signing keys before tagging (any newer signed stable release can be installed from any version; there is no per-release upgrade path to set). Commit, tag `vx.y.z` and push the tag. The release workflow builds the Linux archives and Debian packages, creates the GitHub Release from both changelogs, then adds the Apple Silicon archive. Stable releases also publish the installer and signed platform manifests. If a tap is configured, the workflow updates its formula after signing all three archives. See the [release configuration](docs/dev/release-updates.md) and [release workflow](.github/workflows/release.yml). +3. Configure the publisher and signing keys before tagging (any newer signed stable release can be installed from any version; there is no per-release upgrade path to set). Commit, tag `vx.y.z` and push the tag. The release workflow builds the Linux archives and Debian packages, creates the GitHub Release from both changelogs, then adds the macOS archives (Apple Silicon, and Intel cross-compiled on the same runner). Stable releases also publish the installer and signed platform manifests. If a tap is configured, the workflow updates its formula after signing all four archives. See the [release configuration](docs/dev/release-updates.md) and [release workflow](.github/workflows/release.yml). 4. Update Glama: on glama.ai, the build steps under this server's *Admin → Dockerfile* pin the version. Change it and rebuild. By contributing you agree that your contributions are licensed under the MIT license, except for changes to vendored files, which stay under their original licenses. diff --git a/README.md b/README.md index aac777b..551d239 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Device control has two routes, picked by iOS version: ## Quick Start -You need an iPhone or iPad (iOS 27+ recommended, iOS 17+ supported) connected by a **data** cable, and an Apple Silicon Mac or a Linux machine. On iOS 26 and earlier you also need a free Apple ID (use a dedicated one) to sign WebDriverAgent. +You need an iPhone or iPad (iOS 27+ recommended, iOS 17+ supported) connected by a **data** cable, and a Mac (macOS 11+, Apple Silicon or Intel) or a Linux machine. On iOS 26 and earlier you also need a free Apple ID (use a dedicated one) to sign WebDriverAgent. **macOS or Linux, one command** (upstream example; for a fork, use the installer asset from its own signed release) @@ -117,7 +117,7 @@ brew install derrors/tap/iphone-control && brew services start iphone-control sudo apt install ./iphone-control__amd64.deb && systemctl --user enable --now iphone-control ``` -On Linux the system usbmuxd is needed (`sudo apt install usbmuxd`; the .deb brings it). On an Intel Mac, build from source. +On Linux the system usbmuxd is needed (`sudo apt install usbmuxd`; the .deb brings it). Intel Mac packages come with 0.2.14 and later; they are cross-compiled on Apple Silicon and were only tested under Rosetta, not yet on a real Intel Mac. **Then, on every system** diff --git a/README.zh-CN.md b/README.zh-CN.md index b0aaef6..c12dbd5 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -95,7 +95,7 @@ iphone-control 在 Linux 或 macOS 上用**一个 Rust 二进制**把这些事 ## 快速开始 -需要一部 iPhone 或 iPad(推荐 iOS 27 及以上,iOS 17 起都能用)和能**传数据**的线,以及一台 Apple Silicon 的 Mac 或一台 Linux 机器。iOS 26 及以下还要一个免费 Apple ID(建议专门注册一个),用来给 WebDriverAgent 签名。 +需要一部 iPhone 或 iPad(推荐 iOS 27 及以上,iOS 17 起都能用)和能**传数据**的线,以及一台 Mac(macOS 11 及以上,Apple Silicon 或 Intel)或一台 Linux 机器。iOS 26 及以下还要一个免费 Apple ID(建议专门注册一个),用来给 WebDriverAgent 签名。 **macOS 或 Linux,一行命令安装** @@ -119,7 +119,7 @@ brew install derrors/tap/iphone-control && brew services start iphone-control sudo apt install ./iphone-control_<版本>_amd64.deb && systemctl --user enable --now iphone-control ``` -Linux 上要用系统的 usbmuxd(`sudo apt install usbmuxd`,.deb 会自动装上)。Intel 芯片的 Mac 请从源码编译。 +Linux 上要用系统的 usbmuxd(`sudo apt install usbmuxd`,.deb 会自动装上)。Intel Mac 的包从 0.2.14 起提供,是在 Apple Silicon 上交叉编译的,只在 Rosetta 下跑过测试,还没在真正的 Intel Mac 上用过。 **装好以后,各系统都一样** diff --git a/apps/iphone-control/src/update.rs b/apps/iphone-control/src/update.rs index 1fe0d5e..6d44e95 100644 --- a/apps/iphone-control/src/update.rs +++ b/apps/iphone-control/src/update.rs @@ -42,6 +42,7 @@ fn tap() -> Option<&'static str> { pub fn target() -> Option<&'static str> { match (std::env::consts::OS, std::env::consts::ARCH) { ("macos", "aarch64") => Some("macos-arm64"), + ("macos", "x86_64") => Some("macos-x86_64"), ("linux", "aarch64") if cfg!(target_env = "gnu") => Some("linux-aarch64"), ("linux", "x86_64") if cfg!(target_env = "gnu") => Some("linux-x86_64"), _ => None, @@ -804,6 +805,8 @@ mod tests { assert_eq!(for_install("0.2.1", InstallMethod::Unknown, None), Availability::Current); assert_eq!(for_install("0.3.0-rc.1", InstallMethod::Unknown, None), Availability::Ahead); assert_eq!(for_install("0.2.0", InstallMethod::Managed, Some("macos-arm64")), Availability::PlatformPending); + // releases before Intel Mac builds have no macos-x86_64 archive: an Intel Mac waits, it isn't offered another + assert_eq!(for_install("0.2.0", InstallMethod::Managed, Some("macos-x86_64")), Availability::PlatformPending); assert_eq!(for_install("0.2.0", InstallMethod::Managed, Some("linux-x86_64")), Availability::PlatformPending); assert_eq!(for_install("0.2.0", InstallMethod::Homebrew, Some("macos-arm64")), Availability::BrewCheck); assert_eq!(for_install("0.2.0", InstallMethod::Debian, Some("linux-x86_64")), Availability::Available); diff --git a/docs/decisions.md b/docs/decisions.md index 53409dd..4578cc0 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -105,6 +105,7 @@ - 原生安装更简单:不用 root、不用 Docker、不用 USB 直通,macOS 和 Linux 是同一套步骤;Mac 上本来就不能用 Docker(Docker Desktop 不支持 USB 直通)。 - 少一套要维护的东西:自管 usbmuxd、容器没有 udev 的热插拔兜底、镜像构建和 SBOM、`docker exec` 形式的注册命令都不要了。 - **代价**:Docker 用户要迁移(数据目录拷到 `~/.local/share/iphone-control`,`.env` 改成 `~/.config/iphone-control/env`,手机可能要重新信任,见更新日志的升级注意事项);Linux 上要自己装 usbmuxd;不能再用容器把它和宿主机隔离开,守护进程的权限就是登录用户的权限;Intel Mac 没有预编译版本,要从源码编译。 +- **补充(2026-11-24)**:Intel Mac 有了预编译包(`macos-x86_64`,#181),install.sh、Homebrew、`iphone-control update` 都支持。在 Apple Silicon 的 runner 上交叉编译,不用越来越少的 Intel runner;Rosetta 下跑一遍 `--version`。最低系统和 Apple Silicon 一样是 macOS 11,写在 `.cargo/config.toml`:Rust 对 x86_64 的默认是 10.12,这时链接 CoreMedia 会带进一个经 `@rpath` 找的 Swift 库,程序起不来。代价:没有 Intel Mac 做真机验证,只在 Rosetta 下跑过全部单测;VideoToolbox 在 Intel 上用的是另一套硬件编码器,画质参数没测过。 - **重新评估**:有人需要在无人值守的服务器上隔离运行、又不用控制台的 AI 任务时。 ## D15:控制台画面用 H.264,调用外部 ffmpeg,显卡编码优先(2026-11-11) diff --git a/docs/dev/release-updates.md b/docs/dev/release-updates.md index 3bbe981..84e1d7f 100644 --- a/docs/dev/release-updates.md +++ b/docs/dev/release-updates.md @@ -22,7 +22,7 @@ openssl genpkey -algorithm ED25519 -out signing-key.pem openssl pkey -in signing-key.pem -pubout -outform DER | tail -c 32 | od -An -v -tx1 | tr -d ' \n' ``` -The stable tag must match the workspace package version, e.g. `v0.2.1` for `0.2.1`. The workflow checks the uploaded archives against the build output before signing the manifest bytes for each target. Linux and Apple Silicon macOS have independent signing jobs. During a partial release, a platform can have an archive before its signed manifest appears. +The stable tag must match the workspace package version, e.g. `v0.2.1` for `0.2.1`. The workflow checks the uploaded archives against the build output before signing the manifest bytes for each target. Linux and macOS (Apple Silicon and Intel) have independent signing jobs. During a partial release, a platform can have an archive before its signed manifest appears. ## Roll out a release diff --git a/packaging/homebrew/formula.sh b/packaging/homebrew/formula.sh index 4eacd35..3d88776 100755 --- a/packaging/homebrew/formula.sh +++ b/packaging/homebrew/formula.sh @@ -1,10 +1,11 @@ #!/bin/sh # Prints the Homebrew formula for one release: -# packaging/homebrew/formula.sh v0.2.1 +# packaging/homebrew/formula.sh v0.2.1 \ +# # The formula installs the prebuilt binary from the GitHub release; `brew services start iphone-control` runs the # daemon (launchd on macOS, systemd on Linux) with the settings in ~/.config/iphone-control/env. set -eu -[ $# -eq 4 ] || { echo "usage: $0 vX.Y.Z SHA_MACOS_ARM64 SHA_LINUX_X86_64 SHA_LINUX_AARCH64" >&2; exit 2; } +[ $# -eq 5 ] || { echo "usage: $0 vX.Y.Z SHA_MACOS_ARM64 SHA_MACOS_X86_64 SHA_LINUX_X86_64 SHA_LINUX_AARCH64" >&2; exit 2; } tag="$1" repo="${ICTL_UPDATE_PUBLISHER:?set the release publisher as owner/repo}" base="https://github.com/$repo/releases/download/$tag/iphone-control-$tag" @@ -16,21 +17,25 @@ class IphoneControl < Formula license "MIT" on_macos do - depends_on arch: :arm64 + depends_on macos: :big_sur on_arm do url "$base-macos-arm64.tar.gz" sha256 "$2" end + on_intel do + url "$base-macos-x86_64.tar.gz" + sha256 "$3" + end end on_linux do on_intel do url "$base-linux-x86_64.tar.gz" - sha256 "$3" + sha256 "$4" end on_arm do url "$base-linux-aarch64.tar.gz" - sha256 "$4" + sha256 "$5" end end diff --git a/packaging/installer.py b/packaging/installer.py index 8cd478c..6899287 100644 --- a/packaging/installer.py +++ b/packaging/installer.py @@ -148,6 +148,17 @@ def run(*args): return subprocess.run(args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0 +def release_target(system, machine, arm64_capable): + """The release archive for this machine, or None. A Mac that can run arm64 code gets the Apple Silicon build + even when this Python runs under Rosetta (it then reports x86_64).""" + machine = machine.lower() + if system == "darwin": + return "macos-arm64" if machine == "arm64" or arm64_capable() else "macos-x86_64" + if system == "linux" and machine in ("x86_64", "aarch64"): + return "linux-" + machine + return None + + def service_files(config): if sys.platform == "darwin": return "launchd", Path.home() / "Library/LaunchAgents" / (LABEL + ".plist") @@ -461,12 +472,8 @@ def main(): raise ValueError("unbound source installer; download install.sh from your publisher's GitHub Release assets") if os.getuid() == 0: raise ValueError("run as your regular user") - arch = platform.machine().lower() - if sys.platform == "darwin" and (arch == "arm64" or run("arch", "-arm64", "/usr/bin/true")): - target = "macos-arm64" - elif sys.platform == "linux" and arch in ("x86_64", "aarch64"): - target = "linux-" + arch - else: + target = release_target(sys.platform, platform.machine(), lambda: run("arch", "-arm64", "/usr/bin/true")) + if target is None: raise ValueError("no supported release for this platform") binary_dir = (args.prefix / "bin").resolve() binary_dir.mkdir(mode=0o755, parents=True, exist_ok=True) diff --git a/packaging/licenses/about.toml b/packaging/licenses/about.toml index 96fa110..5d05609 100644 --- a/packaging/licenses/about.toml +++ b/packaging/licenses/about.toml @@ -4,6 +4,6 @@ accepted = [ "MIT", "Apache-2.0", "Apache-2.0 WITH LLVM-exception", "BSD-2-Clause", "BSD-3-Clause", "ISC", "MPL-2.0", "Unicode-3.0", "Zlib", "CC0-1.0", "0BSD", "BSL-1.0", "Unlicense", "CDLA-Permissive-2.0", "BlueOak-1.0.0", ] -targets = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "aarch64-apple-darwin"] +targets = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-apple-darwin"] ignore-build-dependencies = true ignore-dev-dependencies = true diff --git a/packaging/release.py b/packaging/release.py index 7457f93..5cd0816 100644 --- a/packaging/release.py +++ b/packaging/release.py @@ -15,7 +15,7 @@ SLUG = r"[A-Za-z0-9][A-Za-z0-9-]*/[A-Za-z0-9][A-Za-z0-9_.-]*" NUMBER = r"(?:0|[1-9][0-9]*)" STABLE = rf"v{NUMBER}\.{NUMBER}\.{NUMBER}" -TARGETS = ("linux-x86_64", "linux-aarch64", "macos-arm64") +TARGETS = ("linux-x86_64", "linux-aarch64", "macos-arm64", "macos-x86_64") DEB_ARCH = {"linux-x86_64": "amd64", "linux-aarch64": "arm64"} # 0.2.2's updater refuses a manifest without these two fields and installs only when `rollback_from` is its own # version (rollback was removed after it). Written into archive manifests so 0.2.2 can still upgrade with diff --git a/packaging/test_installer.py b/packaging/test_installer.py index 0d8a840..326b131 100644 --- a/packaging/test_installer.py +++ b/packaging/test_installer.py @@ -58,7 +58,8 @@ def setUp(self): })) self.stack.enter_context(patch.multiple(installer, PUBLISHER=REPO, PUBLIC_KEYS=pub)) self.stack.enter_context(patch.object(installer, "download", self.download)) - self.target = "macos-arm64" if sys.platform == "darwin" else "linux-" + platform.machine() + self.target = installer.release_target(sys.platform, platform.machine(), + lambda: installer.run("arch", "-arm64", "/usr/bin/true")) self.name = f"iphone-control-v{VERSION}-{self.target}" self.archive = self.dist / (self.name + ".tar.gz") self.manifest = self.dist / (self.name + ".manifest.json") @@ -107,6 +108,16 @@ def install(self, *args): with patch.object(sys, "argv", ["install.sh", "--prefix", str(self.prefix), *args]): installer.main() + def test_release_target(self): + never, always = (lambda: False), (lambda: True) + self.assertEqual(installer.release_target("darwin", "arm64", never), "macos-arm64") + self.assertEqual(installer.release_target("darwin", "x86_64", always), "macos-arm64", "Python under Rosetta") + self.assertEqual(installer.release_target("darwin", "x86_64", never), "macos-x86_64", "an Intel Mac") + self.assertEqual(installer.release_target("linux", "x86_64", always), "linux-x86_64") + self.assertEqual(installer.release_target("linux", "aarch64", never), "linux-aarch64") + self.assertIsNone(installer.release_target("linux", "armv7l", never)) + self.assertIsNone(installer.release_target("freebsd", "amd64", never)) + def test_install_and_uninstall(self): with contextlib.redirect_stdout(io.StringIO()) as output: self.install() diff --git a/website/deploy/macos.md b/website/deploy/macos.md index a778db3..13058d1 100644 --- a/website/deploy/macos.md +++ b/website/deploy/macos.md @@ -3,12 +3,12 @@ iphone-control 也能直接跑在 Mac 上:用 macOS 自带的 usbmuxd,不需要 Xcode,也不需要付费开发者账号。和 Linux 上基本一样,区别见文末的[已知差异](#已知差异)。 ::: info 验证情况 -已在 MacBook Pro(Apple M3 Pro)/ macOS 26.6.2 + iPhone 15 Pro Max / iOS 27.0.1 上验证:安装向导、当时的全部 MCP 工具、开着 Finder 连续操作、同一条隧道连续 30 分钟、拔插和手机重启后自动恢复。这次验证早于 0.1.3,多设备工具(`iphone_list_devices`、`iphone_select_device`)没有在 macOS 上验证过。Intel Mac 还没测过。验证步骤和结果见 [macOS 真机验证](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md)。 +已在 MacBook Pro(Apple M3 Pro)/ macOS 26.6.2 + iPhone 15 Pro Max / iOS 27.0.1 上验证:安装向导、当时的全部 MCP 工具、开着 Finder 连续操作、同一条隧道连续 30 分钟、拔插和手机重启后自动恢复。这次验证早于 0.1.3,多设备工具(`iphone_list_devices`、`iphone_select_device`)没有在 macOS 上验证过。Intel Mac 的包从 0.2.14 起提供,是在 Apple Silicon 上交叉编译的,只在 Rosetta 下跑过测试,还没在真正的 Intel Mac 上用过。验证步骤和结果见 [macOS 真机验证](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md)。 ::: ## 需要 -- Apple Silicon 的 Mac。用脚本安装时,PATH 中需要有 Python 3 和 OpenSSL 3。Intel Mac 要从源码编译,需 Xcode 命令行工具和 Rust 1.89 以上。 +- macOS 11 及以上的 Mac,Apple Silicon 或 Intel(Intel 的包从 0.2.14 起提供;更早的版本要从源码编译,需 Xcode 命令行工具和 Rust 1.89 以上)。用脚本安装时,PATH 中需要有 Python 3 和 OpenSSL 3。 - 一部 iPhone 或 iPad,用能**传数据**的线连接。推荐 iOS 27 及以上(原生控制);iOS 17 起都能用 - iOS 26 及以下还要一个免费 Apple ID(建议专门注册一个) @@ -33,7 +33,7 @@ brew services start iphone-control # 守护进程常驻,登录后自动 服务同样读取 `~/.config/iphone-control/env`,日志在 `$(brew --prefix)/var/log/iphone-control.log`。设置模板在 `$(brew --prefix)/opt/iphone-control/share/iphone-control/env.example`。 -### 从源码编译(Intel Mac) +### 从源码编译 需要 Xcode 命令行工具和 Rust 1.89 以上,M3 Pro 上约 2 分半: @@ -137,11 +137,11 @@ rm -rf ~/.local/share/iphone-control ~/.config/iphone-control # 会删掉 Appl | | Linux | macOS | |---|---|---| -| 安装 | 一行命令、Homebrew、deb 或从源码编译 | 一行命令、Homebrew 或从源码编译(只有 Apple Silicon 的包) | +| 安装 | 一行命令、Homebrew、deb 或从源码编译 | 一行命令、Homebrew 或从源码编译(Apple Silicon 和 Intel 的包) | | 常驻 | systemd 用户服务 | launchd 用户服务 | | usbmuxd | 系统包,插上手机时由 udev 拉起 | macOS 自带,一直在运行 | | 数据目录 | `~/.local/share/iphone-control` | 同左(不是 Mac 习惯的 `~/Library/Application Support`) | | 控制接口 | `$XDG_RUNTIME_DIR/iphone-control/ctl.sock` | `~/.local/share/iphone-control/ctl.sock` | | 配对记录 | `/var/lib/lockdown` | `/var/db/lockdown`(和 Finder 共用) | -还没在 Mac 上验证过的:Xcode 的「设备与模拟器」窗口开着时会不会抢连接、手机第一次在这台 Mac 上配对的流程、iPad、接多台设备、Intel Mac。遇到问题欢迎[反馈](https://github.com/Derrors/iphone-control/issues)。 +还没在 Mac 上验证过的:Xcode 的「设备与模拟器」窗口开着时会不会抢连接、手机第一次在这台 Mac 上配对的流程、iPad、接多台设备、真正的 Intel Mac(Intel 的包只在 Rosetta 下测过)。遇到问题欢迎[反馈](https://github.com/Derrors/iphone-control/issues)。 diff --git a/website/deploy/source.md b/website/deploy/source.md index 1b5eed5..ef2eb9a 100644 --- a/website/deploy/source.md +++ b/website/deploy/source.md @@ -1,6 +1,6 @@ # 从源码编译 -一般用不着:一行命令、Homebrew 和 deb 包装的都是 Release 里编好的程序,见[快速开始](../guide/getting-started#install)。没有预编译包的机器(Intel Mac)和参与开发时才从源码编译。在 Mac 上见 [macOS](./macos)。 +一般用不着:一行命令、Homebrew 和 deb 包装的都是 Release 里编好的程序,见[快速开始](../guide/getting-started#install)。没有预编译包的机器(0.2.14 以前的 Intel Mac)和参与开发时才从源码编译。在 Mac 上见 [macOS](./macos)。 ## 准备 diff --git a/website/en/deploy/macos.md b/website/en/deploy/macos.md index bbb34e5..9c43fcb 100644 --- a/website/en/deploy/macos.md +++ b/website/en/deploy/macos.md @@ -3,12 +3,12 @@ iphone-control also runs directly on a Mac, using the usbmuxd that ships with macOS. No Xcode and no paid developer account. It works much like on Linux; the differences are listed under [Known differences](#known-differences). ::: info Verified -Verified on a MacBook Pro (Apple M3 Pro) / macOS 26.6.2 with an iPhone 15 Pro Max / iOS 27.0.1: the setup wizard, every MCP tool at that time, continuous use with Finder open, one tunnel kept busy for 30 minutes, and recovery after unplugging and phone reboots. This predates 0.1.3: the multi-device tools (`iphone_list_devices`, `iphone_select_device`) haven't been verified on macOS. Intel Macs are untested. Steps and results: [macOS verification](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md) (in Chinese). +Verified on a MacBook Pro (Apple M3 Pro) / macOS 26.6.2 with an iPhone 15 Pro Max / iOS 27.0.1: the setup wizard, every MCP tool at that time, continuous use with Finder open, one tunnel kept busy for 30 minutes, and recovery after unplugging and phone reboots. This predates 0.1.3: the multi-device tools (`iphone_list_devices`, `iphone_select_device`) haven't been verified on macOS. Intel Mac packages come with 0.2.14 and later; they are cross-compiled on Apple Silicon and were only tested under Rosetta, not yet on a real Intel Mac. Steps and results: [macOS verification](https://github.com/Derrors/iphone-control/blob/main/docs/dev/macos-verification.md) (in Chinese). ::: ## You need -- An Apple Silicon Mac. The script installer requires Python 3 and OpenSSL 3 on PATH. Intel Macs have no prebuilt package and build from source (Xcode Command Line Tools and Rust 1.89+). Full Xcode is **not** needed +- A Mac on macOS 11 or later, Apple Silicon or Intel (Intel packages from 0.2.14; earlier versions build from source with Xcode Command Line Tools and Rust 1.89+). The script installer requires Python 3 and OpenSSL 3 on PATH. Full Xcode is **not** needed - An iPhone or iPad, connected with a cable that carries **data**. iOS 27 or later is recommended (native control); iOS 17 and later work - On iOS 26 and earlier, a free Apple ID (a dedicated one is recommended) @@ -33,7 +33,7 @@ brew services start iphone-control # the daemon runs now and after each log This service also reads `~/.config/iphone-control/env` and logs to `$(brew --prefix)/var/log/iphone-control.log`. The settings template is `$(brew --prefix)/opt/iphone-control/share/iphone-control/env.example`. -### Build from source (Intel Macs) +### Build from source You need the Xcode Command Line Tools and Rust 1.89+; about 2½ minutes on an M3 Pro: @@ -137,11 +137,11 @@ If WDA was used, delete the WebDriverAgent app on the phone; its profile under * | | Linux | macOS | |---|---|---| -| Install | One command, Homebrew, .deb or build from source | One command, Homebrew or build from source (packages for Apple Silicon only) | +| Install | One command, Homebrew, .deb or build from source | One command, Homebrew or build from source (packages for Apple Silicon and Intel) | | Keep running | systemd user service | launchd user service | | usbmuxd | System package, started by udev on plug-in | Built into macOS, always running | | Data directory | `~/.local/share/iphone-control` | Same (not the usual `~/Library/Application Support`) | | Control socket | `$XDG_RUNTIME_DIR/iphone-control/ctl.sock` | `~/.local/share/iphone-control/ctl.sock` | | Pairing records | `/var/lib/lockdown` | `/var/db/lockdown` (shared with Finder) | -Not yet verified on a Mac: whether Xcode's *Devices and Simulators* window competes for the connection, pairing a phone with the Mac for the first time, iPads, several devices, and Intel Macs. [Reports](https://github.com/Derrors/iphone-control/issues) are welcome. +Not yet verified on a Mac: whether Xcode's *Devices and Simulators* window competes for the connection, pairing a phone with the Mac for the first time, iPads, several devices, and a real Intel Mac (the Intel package was only tested under Rosetta). [Reports](https://github.com/Derrors/iphone-control/issues) are welcome. diff --git a/website/en/deploy/source.md b/website/en/deploy/source.md index 2a8ae7a..2ffc217 100644 --- a/website/en/deploy/source.md +++ b/website/en/deploy/source.md @@ -1,6 +1,6 @@ # Build from Source -Usually you don't need this: the one-line installer, Homebrew and the .deb all install the program built for the release; see [Getting Started](../guide/getting-started#install). Build from source on machines without a prebuilt package (Intel Macs) and for development. On a Mac, see [macOS](./macos). +Usually you don't need this: the one-line installer, Homebrew and the .deb all install the program built for the release; see [Getting Started](../guide/getting-started#install). Build from source on machines without a prebuilt package (Intel Macs before 0.2.14) and for development. On a Mac, see [macOS](./macos). ## Requirements diff --git a/website/en/guide/getting-started.md b/website/en/guide/getting-started.md index 34b8caf..505485d 100644 --- a/website/en/guide/getting-started.md +++ b/website/en/guide/getting-started.md @@ -49,7 +49,7 @@ Talking to the phone over USB goes through the system's usbmuxd: `sudo apt insta On Linux with ffmpeg installed, the control page's picture is H.264, about 1/15 of the traffic, which is much smoother through a tunnel or over the internet: `sudo apt install ffmpeg`. On macOS it is H.264 without installing anything. See [the control page's picture](./cli#viewer-picture). ::: -Intel Macs have no prebuilt binary and need a build from source, as does development. See [Build from Source](../deploy/source). +The one-line installer and Homebrew work on Apple Silicon and Intel Macs (Intel packages from 0.2.14). Development runs from source; see [Build from Source](../deploy/source). ### Upstream v0.2.0 script installation and migration {#legacy-script} diff --git a/website/en/guide/what-is-iphone-control.md b/website/en/guide/what-is-iphone-control.md index 2a790aa..0cf87ca 100644 --- a/website/en/guide/what-is-iphone-control.md +++ b/website/en/guide/what-is-iphone-control.md @@ -28,7 +28,7 @@ The core is device control: a long-running daemon owns the phone and keeps servi | | | |---|---| -| Host | Linux, x86_64 or arm64: one-command install, Homebrew or a .deb (Debian 12+, Ubuntu 22.04+), with the system usbmuxd; or build from source with Rust 1.89+
macOS, Apple Silicon: one-command install or Homebrew, or build from source, see [macOS](../deploy/macos)
No Windows | +| Host | Linux, x86_64 or arm64: one-command install, Homebrew or a .deb (Debian 12+, Ubuntu 22.04+), with the system usbmuxd; or build from source with Rust 1.89+
macOS 11+, Apple Silicon or Intel (Intel packages from 0.2.14): one-command install or Homebrew, or build from source, see [macOS](../deploy/macos)
No Windows | | Phone | iPhone or iPad, iOS 17 or later. **iOS 27 or later recommended** (native control); iOS 17–26 through WebDriverAgent | | Verified on | iPhone 15 Pro Max, iOS 27.2.1, native control (Linux)
iPhone 15 Pro Max, iOS 27.0.1, WDA (Linux, macOS)
iPhone 12 mini, iOS 26.4.1 (Linux)
iPad mini 5, iOS 26.6.1 (Linux) | | Account | None on iOS 27 and later (native control); on iOS 26 and earlier a free Apple ID, a dedicated one recommended | @@ -57,7 +57,7 @@ The CLI, `doctor` output and MCP tool results are in Simplified Chinese by defau **macOS** -- Prebuilt binaries are for Apple Silicon only; an Intel Mac needs a build from source and is untested. +- Intel Mac packages come with 0.2.14 and later; they are cross-compiled on Apple Silicon and were only tested under Rosetta, not yet on a real Intel Mac. - The prebuilt binary isn't notarized; a copy downloaded with a browser needs its quarantine flag removed first. - Set the phone's charging limit to 100%: with the 80% limit, USB drops about once a minute. diff --git a/website/guide/getting-started.md b/website/guide/getting-started.md index 9a4b4a8..3c4fb7c 100644 --- a/website/guide/getting-started.md +++ b/website/guide/getting-started.md @@ -49,7 +49,7 @@ systemctl --user enable --now iphone-control # 以普通用户运行,每 Linux 上装了 ffmpeg,控制台的画面改用 H.264,流量约为原来的 1/15,经隧道、走外网时更顺:`sudo apt install ffmpeg`。macOS 上不用装,直接就是 H.264。见[控制台的画面](./cli#viewer-picture)。 ::: -Intel Mac 没有预编译版本,要从源码编译;参与开发也从源码运行。见[从源码编译](../deploy/source)。 +一行命令和 Homebrew 在 Apple Silicon 和 Intel 的 Mac 上都能用(Intel 的包从 0.2.14 起提供)。参与开发从源码运行,见[从源码编译](../deploy/source)。 ### 上游 v0.2.0 脚本安装与迁移 {#legacy-script} diff --git a/website/guide/what-is-iphone-control.md b/website/guide/what-is-iphone-control.md index 61e3287..d383964 100644 --- a/website/guide/what-is-iphone-control.md +++ b/website/guide/what-is-iphone-control.md @@ -28,7 +28,7 @@ iphone-control 让 AI agent(例如 Claude)操作一台用数据线接在 Lin | | | |---|---| -| 主机 | Linux,x86_64 或 arm64:一行命令安装、Homebrew 或 deb 包(Debian 12+、Ubuntu 22.04+),要系统的 usbmuxd;也可以用 Rust 1.89+ 从源码编译
macOS,Apple Silicon:一行命令安装或 Homebrew,也可以从源码编译,见 [macOS](../deploy/macos)
不支持 Windows | +| 主机 | Linux,x86_64 或 arm64:一行命令安装、Homebrew 或 deb 包(Debian 12+、Ubuntu 22.04+),要系统的 usbmuxd;也可以用 Rust 1.89+ 从源码编译
macOS 11 及以上,Apple Silicon 或 Intel(Intel 的包从 0.2.14 起提供):一行命令安装或 Homebrew,也可以从源码编译,见 [macOS](../deploy/macos)
不支持 Windows | | 手机 | iPhone 或 iPad,iOS 17 及以上。**推荐 iOS 27 及以上**(原生控制);iOS 17–26 经 WebDriverAgent | | 已在真机验证 | iPhone 15 Pro Max,iOS 27.2.1,原生控制(Linux)
iPhone 15 Pro Max,iOS 27.0.1,WDA(Linux、macOS)
iPhone 12 mini,iOS 26.4.1(Linux)
iPad mini 5,iOS 26.6.1(Linux) | | 账号 | iOS 27 及以上(原生控制)不需要;iOS 26 及以下要一个免费 Apple ID,建议专门注册一个 | @@ -57,7 +57,7 @@ iphone-control 让 AI agent(例如 Claude)操作一台用数据线接在 Lin **macOS** -- 预编译版本只支持 Apple Silicon;Intel Mac 要从源码编译,没测过。 +- Intel Mac 的包从 0.2.14 起提供,是在 Apple Silicon 上交叉编译的,只在 Rosetta 下跑过测试,还没在真正的 Intel Mac 上用过。 - 预编译二进制没有经过苹果公证,用浏览器下载的要先去掉隔离标记。 - 手机的充电上限要改成 100%,开着「80% 上限」时 USB 大约每分钟断开一次。