From e35b8adbe048d0802705f985f6f58c5015d0c6db Mon Sep 17 00:00:00 2001 From: LNP <90243050+LNPANDY@users.noreply.github.com> Date: Sat, 7 Nov 2026 22:16:28 +0000 Subject: [PATCH] =?UTF-8?q?fix(ios):=20=E6=BF=80=E6=B4=BB=20custom-protoco?= =?UTF-8?q?l=20=E7=89=B9=E6=80=A7=E5=B9=B6=E9=85=8D=E7=BD=AE=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E8=B5=84=E6=BA=90=E5=B5=8C=E5=85=A5=EF=BC=8C=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E8=BF=9B=E5=85=A5=20dev=20=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-ios.yml | 20 +++++++++++++++++--- src-tauri/Cargo.toml | 4 ++++ src-tauri/tauri.ios.conf.json | 6 ++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src-tauri/tauri.ios.conf.json diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml index 9c09d61..1385a60 100644 --- a/.github/workflows/build-ios.yml +++ b/.github/workflows/build-ios.yml @@ -67,9 +67,9 @@ jobs: # 1. 确保前端编译产物就绪 pnpm build - # 2. 执行 Tauri iOS 自动化构建(免证书签名) - echo "=== 执行 Tauri iOS 构建 (--no-sign) ===" - pnpm tauri ios build --no-sign --ci || true + # 2. 执行 Tauri iOS 自动化构建(免证书签名,激活 custom-protocol 确保为生产打包模式) + echo "=== 执行 Tauri iOS 构建 (--no-sign --features custom-protocol) ===" + pnpm tauri ios build --no-sign --ci --features custom-protocol || true # 3. 检查是否已直接生成 IPA IPA_PATH=$(find src-tauri/gen/apple -name "*.ipa" 2>/dev/null | head -n 1 || true) @@ -114,6 +114,20 @@ jobs: if [ -s "artifacts/HGhub_${V}_ios.ipa" ]; then echo "=== IPA 打包成功 ===" ls -lh artifacts/ + + # 5. 校验 IPA 是否为真正的生产包(验证不含 localhost:1420 且静态资源嵌入) + echo "=== 校验生产包模式 ===" + mkdir -p /tmp/verify_ipa + unzip -q -o "artifacts/HGhub_${V}_ios.ipa" -d /tmp/verify_ipa + BIN_PATH=$(find /tmp/verify_ipa -type f -name "HGhub" | head -n 1 || true) + if [ -n "$BIN_PATH" ]; then + if strings "$BIN_PATH" | grep -q "localhost:1420"; then + echo "::error::警告:构建产物依然包含 localhost:1420,处于 dev 模式!" + exit 1 + fi + echo "=== 生产模式校验通过:未包含 devUrl,静态前端资源已内置 ===" + fi + rm -rf /tmp/verify_ipa else echo "::error::未能生成有效的 iOS IPA 文件" exit 1 diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1d523c6..131d6d0 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -14,6 +14,10 @@ crate-type = ["staticlib", "cdylib", "rlib"] [build-dependencies] tauri-build = { version = "2", features = [] } +[features] +default = ["custom-protocol"] +custom-protocol = ["tauri/custom-protocol"] + [dependencies] tauri = { version = "2", features = [] } serde = { version = "1", features = ["derive"] } diff --git a/src-tauri/tauri.ios.conf.json b/src-tauri/tauri.ios.conf.json new file mode 100644 index 0000000..8ef561f --- /dev/null +++ b/src-tauri/tauri.ios.conf.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "build": { + "devUrl": null + } +}