Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 的推送上会跳过,这时照样跑
Expand All @@ -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 里,仍是卡点)。
Expand Down Expand Up @@ -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

Expand Down
84 changes: 59 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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 }}

Expand Down Expand Up @@ -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*
Expand All @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

## [Unreleased]

### 新功能

- Intel 芯片的 Mac(macOS 11 及以上)有了预编译版本,可以用一行命令、Homebrew 安装,也能用 `iphone-control update` 升级(#181)。这个包是交叉编译的,还没在真正的 Intel Mac 上测过,遇到问题欢迎反馈。

### 修复

- 手机上的 WebDriverAgent 只在手机本机监听,同一 Wi-Fi 里的其他设备不能再访问它的 8100(没有认证的操作接口)和 9100(画面)端口。升级后,旧版本在后台启动的 WDA 会被重新启动一次。
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -117,7 +117,7 @@ brew install derrors/tap/iphone-control && brew services start iphone-control
sudo apt install ./iphone-control_<version>_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**

Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,一行命令安装**

Expand All @@ -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 上用过。

**装好以后,各系统都一样**

Expand Down
3 changes: 3 additions & 0 deletions apps/iphone-control/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
Loading
Loading