dsh-ipa-build 0.0.0-stage → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ipa-builder contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,87 @@
1
- # Temporary Holding Version
1
+ # 产出 IPA
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 插件包名 `dsh-ipa-build`。装的时候 `dsh plugin add dsh-ipa-build`,或者直接把目录拷进 DSH 的插件目录。
4
+
5
+ 装好这套东西,本机就能把 Objective-C 源码编成 `.ipa`,也能把现成的 `.app` 打包、改标识、重新签名。Windows 一样能用,不用装 WSL,也不用自己去找 SDK。
6
+
7
+ ## 装
8
+
9
+ 先跑一次,之后不用管它装了什么:
10
+
11
+ ```bash
12
+ # Linux / macOS
13
+ bash scripts/bootstrap.sh
14
+ ```
15
+
16
+ ```powershell
17
+ # Windows
18
+ powershell -ExecutionPolicy Bypass -File scripts\bootstrap.ps1
19
+ ```
20
+
21
+ 东西都落在 `~/.ipa-toolchain`(Windows 是 `%USERPROFILE%\.ipa-toolchain`)。脚本可以反复跑,装过的跳过。
22
+
23
+ SDK、ldid、libplist、zsign 都在 `vendor/`,这几个不用联网。编译器脚本自己解决:
24
+
25
+ - Linux:apt 装 clang 和 lld
26
+ - macOS:先用 `xcode-select --install` 装命令行工具(系统会弹一次确认框,点掉就行),再从 brew 装 llvm 拿 `ld64.lld`
27
+ - Windows:先找机器里已有的 LLVM(PATH、Program Files、winget 装过的位置),没有就自己下载解压到工具链目录,断了重跑会接着下
28
+
29
+ 装完路径都写进 `~/.ipa-toolchain/env.sh` 或用户 PATH,`doctor` 能看到。除了 macOS 那个系统弹窗,不需要你动手装别的东西。
30
+
31
+ ## 用
32
+
33
+ ```bash
34
+ # 源码 -> ipa
35
+ scripts/ipa build ./myapp --name MyApp --bundle-id com.you.myapp
36
+
37
+ # 现成的 .app -> ipa,顺手改标识做多开
38
+ scripts/ipa pack MyApp.app -o dist/MyApp.ipa --bundle-id com.you.myapp2
39
+
40
+ # 已有的包重签
41
+ scripts/ipa resign old.ipa -o new.ipa
42
+
43
+ # 看包里是什么
44
+ scripts/ipa info dist/MyApp.ipa
45
+ ```
46
+
47
+ Windows 上把 `scripts/ipa` 换成 `scripts\ipa.ps1`,子命令和参数一样。
48
+
49
+ ## 用手上的证书签
50
+
51
+ 手里有开发者证书(p12 加 mobileprovision)时,sign 走真签名,不再用 ad-hoc:
52
+
53
+ ```bash
54
+ scripts/ipa resign old.ipa -o new.ipa --p12 dev.p12 --prov app.mobileprovision --password 证书密码
55
+ scripts/ipa pack MyApp.app -o dist/MyApp.ipa --p12 dev.p12 --prov app.mobileprovision --password 证书密码
56
+ ```
57
+
58
+ `build` 也认这三个参数。bundle id 要跟描述文件里的对上,对不上签名会失败。
59
+
60
+ Windows 上的 zsign 会拿 p12 走完整签名链,装到未越狱设备也能跑。这一步 zsign 会联网查证书吊销状态(OCSP),网络不通时可能慢一点,或者报个警告。
61
+
62
+ Linux / macOS 上的证书签名也要 zsign,但官方 release 只发了 Windows 版,得自己编一个放进 `~/.ipa-toolchain/bin/zsign`,或者把它放到 PATH 里。没有 zsign 的时候这两台机器只能 ad-hoc 伪签。
63
+
64
+ ## 平台差异
65
+
66
+ `pack`、`resign`、`info` 三个命令在两边完全一样,不依赖编译器。`build` 需要 clang 和 ld64.lld:Linux / macOS 跑 bootstrap 就有了;Windows 上 bootstrap 会装好 LLVM,装不上时如果机器里有 WSL,`build` 会自动转给 WSL 里的 bash 版本跑。
67
+
68
+ ## 签出来的是什么
69
+
70
+ ad-hoc 伪签名:有 CodeDirectory,没有 CMS 块。越狱设备和 TrollStore 能装,普通手机装不上,那种情况用上面说的 p12 走真签名。
71
+
72
+ Swift 不在范围内,`swiftc` 只有 Apple 工具链里有。
73
+
74
+ ## 自检
75
+
76
+ ```bash
77
+ scripts/ipa build scripts/examples/HelloApp --name HelloApp --bundle-id com.example.helloapp
78
+ scripts/ipa info dist/HelloApp.ipa
79
+ ```
80
+
81
+ `info` 里签名那行写着「有 CodeDirectory」,说明编译、打包、签名这条链路通了。没有编译器的机器,用 `pack` 打这个例子也能验证打包和签名。
82
+
83
+ ## vendor 里的东西
84
+
85
+ - `iPhoneOS16.5.sdk.tar.xz`:16.5 的 iPhoneOS SDK。包里的 `.tbd` 已经全部展开成真文件,Windows 解包不会拿到空壳。sha256 `1d55ed9e66a37c0e6813c5be29df6f64f1ce448f58911a6cb87db07d5f6b8c58`
86
+ - `zsign/zsign.exe`:签名工具,来自 https://github.com/zhlynn/zsign 的 v1.1.3 Windows 版。MD5 `c42f137b76eb4cb2cad2b1a227a0f8f0`
87
+ - `libplist-2.6.0.tar.bz2`、`ldid-master/`:Linux / macOS 上编 ldid 用
package/SKILL.md ADDED
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: dsh-ipa-build
3
+ version: 1.2.2
4
+ description: 把 iOS 程序打包成 .ipa。机器上有编译器时可以直接把 Objective-C/C/C++ 源码编成 arm64 安装包;没有编译器时也能把现成的 .app 打成 ipa、给已有的 ipa 重做伪签名、改 bundle id 做多开。SDK、ldid、zsign 都在插件里,跑一次自带的 bootstrap 就把编译器也装好,用户不用手动装任何东西。不碰 Swift,也不做 App Store 上架。
5
+ ---
6
+
7
+ # 产出 IPA
8
+
9
+ 装好这个插件以后,本机就多了一套 iOS 打包环境,你可以直接干活,不用再回头问用户"你装了 Xcode 吗"。
10
+
11
+ 环境是这么放的:SDK 压缩包、ldid 源码、libplist 源码、zsign.exe 都在 `vendor/` 里,bootstrap 把它们铺到 `~/.ipa-toolchain`(Windows 上是 `%USERPROFILE%\.ipa-toolchain`)。这几个不用联网。编译器由 bootstrap 自己解决,Windows 上它会先找机器里已有的 LLVM,找不到就下载解压,装完把路径写进用户 PATH,不需要用户动手。
12
+
13
+ ## 先把环境铺一遍
14
+
15
+ Linux / macOS:
16
+
17
+ ```bash
18
+ bash scripts/bootstrap.sh
19
+ ```
20
+
21
+ Windows(PowerShell):
22
+
23
+ ```powershell
24
+ powershell -ExecutionPolicy Bypass -File scripts\bootstrap.ps1
25
+ ```
26
+
27
+ 两个脚本都可以反复跑,已经装好的部分会跳过,下载断了重跑会接着下。铺完会给一份 doctor 清单,哪行写着"缺"就是哪一环没成。这些都是脚本该干的事,别让用户自己去装 LLVM、装 WSL。
28
+
29
+ ## 这台机器能做到哪一步
30
+
31
+ 得先看清楚机器,别一条命令下去才发现编不了。
32
+
33
+ **Linux / macOS**:`build`、`pack`、`resign`、`info` 全都能用。前提是 bootstrap 已经把 clang 和 ld64.lld 装上:Linux 从 apt 拿 clang + lld;macOS 先装 Xcode 命令行工具(系统弹窗确认一次),再从 brew 装 llvm 取 `ld64.lld`。
34
+
35
+ **Windows**:`pack`、`resign`、`info` 一定能用,靠的是插件里带的 zsign.exe 和 .NET 自带的 zip。`build` 要看有没有 clang:
36
+
37
+ - 跑过 `bootstrap.ps1` 之后,编译器已经在本机了,直接编;
38
+ - 万一本机实在搞不定编译器,而机器里有 WSL,`build` 会自动把活交给 WSL 里的 `scripts/ipa`,你还是敲同一条命令;
39
+ - 两个都不可用的极端情况,`pack` 和 `resign` 照常能用,先把包做出来;编译这条路等 bootstrap 装完再走。
40
+
41
+ `doctor` 会把这几项列出来,先看一眼再决定用哪条路子。
42
+
43
+ ## 命令
44
+
45
+ Linux / macOS 用 `scripts/ipa`,Windows 用 `scripts\ipa.ps1`,子命令和参数是一样的。
46
+
47
+ **doctor** —— 看环境
48
+
49
+ ```
50
+ scripts/ipa doctor
51
+ ```
52
+
53
+ **info** —— 看一个包是什么来路
54
+
55
+ ```
56
+ scripts/ipa info dist/HelloApp.ipa
57
+ ```
58
+
59
+ 会给标识符、版本、最低系统、架构、大小,以及有没有 CodeDirectory。给用户解释"这个包装不装得上"之前先跑这个。
60
+
61
+ **build** —— 源码编成 ipa
62
+
63
+ ```
64
+ scripts/ipa build ./我的源码 --name Hello --bundle-id com.you.hello
65
+ ```
66
+
67
+ 参数:
68
+
69
+ - `--name` 应用名,也是可执行文件名和产物名,不填用目录名
70
+ - `--bundle-id` 默认 `com.example.app`
71
+ - `--min-ios` 默认 14.0。给旧设备就要调低,编高了装不上
72
+ - `--framework` 可以重复。不填的话脚本会看源码里有没有 `UIKit/`,有就链 UIKit + Foundation,没有就只链 Foundation
73
+ - `--entitlements` 签名用的 plist,越狱环境常要 `get-task-allow`、`platform-application`
74
+ - `--icon` 一张 PNG,塞成 `AppIcon60x60@2x.png`
75
+ - `--p12` `--prov` `--password` 有证书就走真签名,见下面「换证书签」
76
+ - `-o` 输出路径,默认 `./dist/<name>.ipa`
77
+
78
+ **pack** —— 现成的 .app 打成 ipa,顺便能改东西
79
+
80
+ ```
81
+ scripts/ipa pack Some.app -o dist/Some.ipa --bundle-id com.you.other --name 分身
82
+ ```
83
+
84
+ `pack` 和 `resign` 同样认 `--p12` `--prov` `--password`,带上就走真签名。
85
+
86
+ `--bundle-id` 换了就是另一个应用,装在同一台机器上不冲突,做多开就靠这个。`--name` 改了显示名,脚本会连可执行文件名一起改(只改 plist 里的名字会让包起不来,这个坑踩过)。
87
+
88
+ **resign** —— 已有的包重签
89
+
90
+ ```
91
+ scripts/ipa resign 旧包.ipa -o 新包.ipa
92
+ ```
93
+
94
+ 会把 `_CodeSignature` 删掉重签,包里带的 dylib 也一起签。拿到别人的包、或者签名过期了,用这个。
95
+
96
+ ## 换证书签(p12 + mobileprovision)
97
+
98
+ ```
99
+ scripts/ipa resign 旧包.ipa -o 新包.ipa --p12 dev.p12 --prov app.mobileprovision --password 证书密码
100
+ ```
101
+
102
+ 命令行里密码会留在 shell 历史里,用户的密码能让他自己填就让他填。bundle id 必须和描述文件里的一致,不一致 zsign 会直接报签名失败。Windows 上 zsign 拿 p12 走完整签名链,装未越狱设备也能跑,但这一步会联网查 OCSP 吊销状态,没网时可能慢或报警告,不是出错。
103
+
104
+ Linux / macOS 上证书签名同样靠 zsign,官方 release 没有 Linux 版,需要把编好的 zsign 放到 `~/.ipa-toolchain/bin/` 或 PATH 里;没有就还是 ad-hoc 伪签。
105
+
106
+ ## 交付之前自己先过一遍这几条
107
+
108
+ 1. 签出来的是 **ad-hoc 伪签名**:CodeDirectory 有,CMS 块没有。越狱设备和 TrollStore 能装,普通未越狱手机装不上。用户说装不上,先问设备是什么状态,别急着改代码。
109
+ 2. 要装进未越狱设备只能换证书:Apple 开发者证书导出的 p12 加 mobileprovision(设备 UDID 在里面)。用户手上有这对文件时,直接 `--p12 --prov --password` 走真签名,别再拿伪签糊过去。
110
+ 3. **Swift 编不了。** `swiftc` 是 Apple 工具链的一部分,Linux 和 Windows 都没有。碰到 `.swift` 直接说清楚,让对方给编好的 `.app` 走 `pack`,或者改成 Objective-C。
111
+ 4. 编出来的最低系统版本就是 `--min-ios`。别把 16.5 起步的包交给 iOS 15 的机器。
112
+
113
+ ## 想确认它真能用
114
+
115
+ `scripts/examples/HelloApp` 是个能直接编的 UIKit 小例子:
116
+
117
+ ```
118
+ scripts/ipa build scripts/examples/HelloApp --name HelloApp --bundle-id com.example.helloapp
119
+ ```
120
+
121
+ 出 `dist/HelloApp.ipa`,然后 `scripts/ipa info dist/HelloApp.ipa` 看签名那行是不是"有 CodeDirectory",是就通了。
122
+
123
+ Windows 上没编译器也别灰心,拿这个例子先 `pack` 一下,能出包就说明打包和签名这两段是好的。
124
+
125
+ ## 目录
126
+
127
+ ```
128
+ scripts/ipa Linux / macOS 入口
129
+ scripts/ipa.ps1 Windows 入口
130
+ scripts/bootstrap.sh 铺 Linux / macOS 环境
131
+ scripts/bootstrap.ps1 铺 Windows 环境
132
+ scripts/templates/ Info.plist 模板、entitlements 样例
133
+ scripts/examples/ HelloApp
134
+ vendor/ SDK、ldid 源码、libplist 源码、zsign.exe
135
+ ```
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "dsh-ipa-build",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.2.2",
4
+ "description": "把 iOS 源码打成 .ipa 的 DSH 插件。内置 iPhoneOS 16.5 SDK 和 zsign,Linux / macOS / Windows 都能用,装完能编能签。",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/3783485207-cmd/dsh-ipa-build.git"
9
+ },
10
+ "keywords": [
11
+ "dsh-plugin",
12
+ "ipa",
13
+ "ios",
14
+ "packaging",
15
+ "zsign",
16
+ "ldid"
17
+ ],
18
+ "files": [
19
+ "SKILL.md",
20
+ "plugin.json",
21
+ "README.md",
22
+ "LICENSE",
23
+ "scripts",
24
+ "vendor"
25
+ ],
26
+ "engines": {
27
+ "node": ">=16"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ }
6
32
  }
package/plugin.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "产出 IPA",
3
+ "id": "dsh-ipa-build",
4
+ "version": "1.2.2",
5
+ "type": "skill",
6
+ "skill": "SKILL.md",
7
+ "setup": {
8
+ "linux": "bash scripts/bootstrap.sh",
9
+ "darwin": "bash scripts/bootstrap.sh",
10
+ "win32": "powershell -ExecutionPolicy Bypass -File scripts\\bootstrap.ps1"
11
+ },
12
+ "entry": {
13
+ "linux": "scripts/ipa",
14
+ "darwin": "scripts/ipa",
15
+ "win32": "scripts/ipa.ps1"
16
+ },
17
+ "home": "~/.ipa-toolchain",
18
+ "capabilities": [
19
+ "arm64-apple-ios 交叉编译(clang + ld64.lld),Linux / macOS / Windows 都能编,编译器由 bootstrap 自动装好",
20
+ "iPhoneOS16.5 SDK 框架链接,走 SDK 里的 .tbd stub(包内已展开,Windows 解包不会缺符号)",
21
+ "伪签名:Linux/macOS 用 ldid,Windows 用 zsign",
22
+ "带证书签名:--p12 证书 --prov 描述文件 --password 密码,Windows 由 zsign 完成",
23
+ "Payload/*.app -> .ipa 打包,可改 bundle id / 显示名 / 版本 / 图标",
24
+ "已有 ipa 或 app 重签"
25
+ ],
26
+ "commands": {
27
+ "doctor": "ipa doctor",
28
+ "info": "ipa info <x.ipa|x.app>",
29
+ "build": "ipa build <源码目录> --name X --bundle-id com.x.y [--min-ios 14.0] [--framework UIKit] [--entitlements p.plist] [--icon i.png] [--p12 c.p12 --prov p.mobileprovision --password pw] [-o out.ipa]",
30
+ "pack": "ipa pack <Xxx.app> [-o out.ipa] [--bundle-id com.x.y] [--name 显示名] [--version 1.2] [--icon i.png] [--p12 c.p12 --prov p.mobileprovision --password pw]",
31
+ "resign": "ipa resign <x.ipa|x.app> [-o out.ipa] [--bundle-id com.x.y] [--p12 c.p12 --prov p.mobileprovision --password pw]"
32
+ },
33
+ "limits": [
34
+ "Swift 编不了(缺 swiftc),要 Swift 只能让用户给编好的 .app",
35
+ "ad-hoc 签名只装得进越狱设备 / TrollStore,普通设备要开发者证书重签",
36
+ "Linux / macOS 上的证书签名需要自备 zsign 可执行文件(官方只发 Windows 版)",
37
+ "不做 App Store 上架,不碰 FairPlay 解密"
38
+ ]
39
+ }
@@ -0,0 +1,134 @@
1
+ # Windows 这边的一次性安装。跑完就有编译器和签名器,不需要你再手动装任何东西。
2
+ # SDK 和 zsign 都在 vendor 里,直接从插件里拿;编译器没有的话脚本自己去搞。
3
+
4
+ param(
5
+ [string[]]$LlvmUrl = @(
6
+ 'https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz',
7
+ 'https://ghfast.top/https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz',
8
+ 'https://gh-proxy.com/https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz'
9
+ )
10
+ )
11
+
12
+ $ErrorActionPreference = 'Stop'
13
+ $here = Split-Path -Parent $MyInvocation.MyCommand.Path
14
+ $root = Split-Path -Parent $here
15
+ if ($env:IPA_HOME) { $tc = $env:IPA_HOME }
16
+ elseif ($env:USERPROFILE) { $tc = Join-Path $env:USERPROFILE '.ipa-toolchain' }
17
+ else { $tc = Join-Path $HOME '.ipa-toolchain' }
18
+
19
+ foreach ($d in @($tc, (Join-Path $tc 'bin'), (Join-Path $tc 'sdk'))) {
20
+ New-Item -ItemType Directory -Path $d -Force | Out-Null
21
+ }
22
+ Write-Host "装到 $tc"
23
+
24
+ function Test-Llvm($bin) { (Test-Path (Join-Path $bin 'clang.exe')) -and (Test-Path (Join-Path $bin 'ld64.lld.exe')) }
25
+
26
+ # 已有的 LLVM 先认出来,不重复下。PATH 里没有但装过的情况很常见,winget 装完就这样。
27
+ function Find-Llvm {
28
+ $c = Get-Command clang.exe -ErrorAction SilentlyContinue
29
+ $l = Get-Command ld64.lld.exe -ErrorAction SilentlyContinue
30
+ if ($c -and $l) { return (Split-Path -Parent $c.Source) }
31
+ $cand = @(
32
+ (Join-Path $tc 'llvm/bin'),
33
+ 'C:\Program Files\LLVM\bin',
34
+ 'C:\Program Files (x86)\LLVM\bin',
35
+ (Join-Path $env:LOCALAPPDATA 'Programs/LLVM/bin')
36
+ )
37
+ foreach ($p in $cand) { if ($p -and (Test-Llvm $p)) { return $p } }
38
+ return $null
39
+ }
40
+
41
+ function Use-Path($bin) {
42
+ $env:PATH = "$bin;$env:PATH"
43
+ $old = [Environment]::GetEnvironmentVariable('Path', 'User')
44
+ if ($old -and -not $old.Contains($bin)) {
45
+ [Environment]::SetEnvironmentVariable('Path', "$bin;$old", 'User')
46
+ }
47
+ }
48
+
49
+ function Get-LlvmArchive($dest) {
50
+ foreach ($u in $LlvmUrl) {
51
+ Write-Host "下载编译器:$u"
52
+ # --continue-at - 让断掉的下载接着走,重跑脚本不用从头再来
53
+ & curl.exe -L --retry 5 --retry-delay 5 --retry-all-errors --continue-at - --connect-timeout 15 -o $dest $u
54
+ if ($LASTEXITCODE -eq 0 -and (Test-Path $dest) -and ((Get-Item $dest).Length -gt 300MB)) { return $true }
55
+ Write-Host "这个源没成,换下一个"
56
+ }
57
+ return $false
58
+ }
59
+
60
+ # SDK:vendor 里的包已经把 .tbd 软链展开成真文件了,Windows 解包不会再出空文件
61
+ $sdkDir = Join-Path $tc 'sdk/iPhoneOS16.5.sdk'
62
+ if (-not (Test-Path $sdkDir)) {
63
+ $archive = Join-Path $root 'vendor/iPhoneOS16.5.sdk.tar.xz'
64
+ if (-not (Test-Path $archive)) { Write-Host "vendor 里没有 SDK 包,插件不完整"; exit 1 }
65
+ Write-Host "解包 SDK"
66
+ & tar.exe -xJf $archive -C (Join-Path $tc 'sdk')
67
+ if (-not (Test-Path $sdkDir)) { Write-Host "SDK 解包失败,看看 tar.exe 能不能用"; exit 1 }
68
+ }
69
+
70
+ # 万一以后换了旧包,这里扫一遍:.tbd 小得像一行文件名,说明是没展开的软链,按名字补成真文件
71
+ $tbds = Get-ChildItem $sdkDir -Recurse -Filter '*.tbd' -File -ErrorAction SilentlyContinue
72
+ $fixed = 0
73
+ foreach ($t in $tbds) {
74
+ if ($t.Length -gt 300) { continue }
75
+ $txt = (Get-Content $t.FullName -Raw -ErrorAction SilentlyContinue)
76
+ if ($txt -eq $null) { continue }
77
+ $txt = $txt.Trim()
78
+ if ($txt -match '^[\w\.\+\-]+\.tbd$') {
79
+ $target = Join-Path $t.DirectoryName $txt
80
+ if ((Test-Path $target) -and ((Get-Item $target).Length -gt $t.Length)) {
81
+ Copy-Item $target $t.FullName -Force
82
+ $fixed++
83
+ }
84
+ }
85
+ }
86
+ if ($fixed -gt 0) { Write-Host "补了 $fixed 个没展开的 .tbd" }
87
+
88
+ # zsign:Windows 上没有 ldid,签名全靠它
89
+ $zs = Join-Path $tc 'bin/zsign.exe'
90
+ if (-not (Test-Path $zs)) {
91
+ $srcZs = Join-Path $root 'vendor/zsign/zsign.exe'
92
+ if (Test-Path $srcZs) { Copy-Item $srcZs $zs -Force } else { Write-Host "vendor 里没有 zsign.exe,签不了名" }
93
+ }
94
+
95
+ # 编译器:找得到就用,找不到就装上
96
+ $bin = Find-Llvm
97
+ if ($bin) {
98
+ Write-Host "编译器在 $bin"
99
+ Use-Path $bin
100
+ } else {
101
+ $dl = Join-Path $tc 'llvm.tar.xz'
102
+ $ok = $false
103
+ if ((Test-Path $dl) -and ((Get-Item $dl).Length -gt 300MB)) { $ok = $true }
104
+ if (-not $ok) { $ok = Get-LlvmArchive $dl }
105
+
106
+ if (-not $ok) {
107
+ # 官方源和镜像都不通时,试试 winget;装完位置不固定,再找一圈
108
+ $winget = Get-Command winget.exe -ErrorAction SilentlyContinue
109
+ if ($winget) {
110
+ Write-Host "下载不通,用 winget 装"
111
+ & winget install --id LLVM.LLVM -e --silent --accept-package-agreements --accept-source-agreements
112
+ $bin = Find-Llvm
113
+ }
114
+ } elseif ($ok) {
115
+ Write-Host "解压编译器"
116
+ $unpack = Join-Path $tc 'llvm_unpack'
117
+ if (Test-Path $unpack) { Remove-Item $unpack -Recurse -Force }
118
+ New-Item -ItemType Directory -Path $unpack -Force | Out-Null
119
+ & tar.exe -xJf $dl -C $unpack
120
+ $inner = Get-ChildItem $unpack -Directory | Select-Object -First 1
121
+ if ($inner) {
122
+ if (Test-Path (Join-Path $tc 'llvm')) { Remove-Item (Join-Path $tc 'llvm') -Recurse -Force }
123
+ Move-Item $inner.FullName (Join-Path $tc 'llvm') -Force
124
+ }
125
+ Remove-Item $unpack -Recurse -Force -ErrorAction SilentlyContinue
126
+ Remove-Item $dl -Force -ErrorAction SilentlyContinue
127
+ $bin = Find-Llvm
128
+ }
129
+
130
+ if ($bin) { Use-Path $bin; Write-Host "编译器好了:$bin" }
131
+ else { Write-Host "编译器没装上,网络问题,重跑一次 scripts\bootstrap.ps1 会接着下。pack / resign 不用编译器,现在就能用。" }
132
+ }
133
+
134
+ & (Join-Path $here 'ipa.ps1') doctor
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env bash
2
+ # 一次性把环境铺好:SDK、ldid、libplist 都在 vendor/ 里,不用联网;
3
+ # 只有 clang 和 lld 得从系统包里装。
4
+
5
+ set -e
6
+
7
+ here="$(cd "$(dirname "$0")" && pwd)"
8
+ root="$(dirname "$here")"
9
+ tc="${IPA_HOME:-$HOME/.ipa-toolchain}"
10
+
11
+ mkdir -p "$tc/bin" "$tc/sdk" "$tc/src" "$tc/deps"
12
+ echo "装到 $tc"
13
+
14
+ os="$(uname -s)"
15
+
16
+ if [ "$os" = "Darwin" ]; then
17
+ if ! command -v clang >/dev/null 2>&1; then
18
+ echo "缺 Xcode 命令行工具,开始装(系统会弹一个确认框,点一下就行)"
19
+ xcode-select --install >/dev/null 2>&1 || true
20
+ for _ in 1 2 3 4 5 6 7 8; do
21
+ command -v clang >/dev/null 2>&1 && break
22
+ sleep 15
23
+ done
24
+ command -v clang >/dev/null 2>&1 || { echo "命令行工具还在装,装完再跑一次这个脚本"; exit 1; }
25
+ fi
26
+
27
+ # Apple 自带的 clang 不带 ld64.lld,得用 brew 的 llvm
28
+ if ! command -v ld64.lld >/dev/null 2>&1; then
29
+ if ! command -v brew >/dev/null 2>&1; then
30
+ echo "没有 Homebrew,先装一个"
31
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || { echo "Homebrew 没装上(网络问题),装完再跑一次"; exit 1; }
32
+ fi
33
+ echo "装 llvm,里面有 ld64.lld,几百 MB,等一下"
34
+ brew install llvm
35
+ prefix="$(brew --prefix llvm 2>/dev/null || true)"
36
+ [ -n "${prefix:-}" ] || { echo "brew 装完找不到 llvm 目录"; exit 1; }
37
+ ln -sf "$prefix/bin/ld64.lld" "$tc/bin/ld64.lld"
38
+ fi
39
+ else
40
+ if ! command -v clang >/dev/null 2>&1; then
41
+ echo "缺 clang,从 apt 装(源换清华镜像,国内快一点)"
42
+ if [ -f /etc/apt/sources.list ] && ! grep -q tuna /etc/apt/sources.list; then
43
+ sudo sed -i 's|http://archive.ubuntu.com/ubuntu/|https://mirrors.tuna.tsinghua.edu.cn/ubuntu/|g' /etc/apt/sources.list
44
+ sudo sed -i 's|http://security.ubuntu.com/ubuntu/|https://mirrors.tuna.tsinghua.edu.cn/ubuntu/|g' /etc/apt/sources.list
45
+ fi
46
+ sudo mkdir -p /var/lib/apt/lists/partial
47
+ sudo apt-get update -qq || true
48
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq clang lld
49
+ fi
50
+
51
+ # clang 调 ld64.lld 时按这个名字找,系统装的是带版本号的文件,做个软链接
52
+ if ! command -v ld64.lld >/dev/null 2>&1; then
53
+ real="$(ls /usr/bin/ld64.lld-* /usr/lib/llvm-*/bin/ld64.lld 2>/dev/null | head -1)"
54
+ [ -n "$real" ] || { echo "装了 clang 但没 lld,运行: sudo apt install lld"; exit 1; }
55
+ sudo ln -sf "$real" /usr/local/bin/ld64.lld
56
+ fi
57
+ fi
58
+
59
+ if [ ! -f "$tc/deps/lib/libplist-2.0.a" ]; then
60
+ echo "编 libplist"
61
+ rm -rf "$tc/src/libplist-2.6.0"
62
+ tar -xjf "$root/vendor/libplist-2.6.0.tar.bz2" -C "$tc/src"
63
+ ( cd "$tc/src/libplist-2.6.0" && ./configure --prefix="$tc/deps" --disable-cython >/dev/null \
64
+ && make -j"$(nproc)" >/dev/null && make install >/dev/null )
65
+ fi
66
+
67
+ if [ ! -x "$tc/bin/ldid" ]; then
68
+ echo "编 ldid"
69
+ rm -rf "$tc/src/ldid-master"
70
+ cp -r "$root/vendor/ldid-master" "$tc/src/"
71
+ ( cd "$tc/src/ldid-master" && PKG_CONFIG_PATH="$tc/deps/lib/pkgconfig" make -j"$(nproc)" >/dev/null \
72
+ && cp ldid "$tc/bin/ldid" )
73
+ fi
74
+
75
+ if [ ! -d "$tc/sdk/iPhoneOS16.5.sdk" ]; then
76
+ echo "解包 SDK"
77
+ tar -xJf "$root/vendor/iPhoneOS16.5.sdk.tar.xz" -C "$tc/sdk"
78
+ fi
79
+
80
+ # 老包里的 .tbd 是软链,解出来只有几个字节,链接时会缺 libc++ 符号
81
+ tbd="$tc/sdk/iPhoneOS16.5.sdk/usr/lib/libc++.tbd"
82
+ if [ -f "$tbd" ] && [ "$(wc -c <"$tbd")" -lt 1000 ]; then
83
+ echo "SDK 里的 .tbd 是没展开的软链,重新解一份:把 vendor/iPhoneOS16.5.sdk.tar.xz 换成新包"
84
+ exit 1
85
+ fi
86
+
87
+ cat > "$tc/env.sh" <<EOF
88
+ export IPA_HOME="$tc"
89
+ export IPA_SDK="$tc/sdk/iPhoneOS16.5.sdk"
90
+ export IPA_LDID="$tc/bin/ldid"
91
+ export PATH="$tc/bin:$PATH"
92
+ export LD_LIBRARY_PATH="$tc/deps/lib:\${LD_LIBRARY_PATH:-}"
93
+ EOF
94
+
95
+ echo
96
+ "$here/ipa" doctor
97
+ echo
98
+ echo "自检一下:"
99
+ echo " $here/ipa build $here/examples/HelloApp --name HelloApp --bundle-id com.example.helloapp"
@@ -0,0 +1,23 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ @interface AppDelegate : UIResponder <UIApplicationDelegate>
4
+ @property (nonatomic, strong) UIWindow *window;
5
+ @end
6
+
7
+ @implementation AppDelegate
8
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
9
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
10
+ UILabel *label = [[UILabel alloc] initWithFrame:self.window.bounds];
11
+ label.text = @"IPA Build OK";
12
+ label.textAlignment = NSTextAlignmentCenter;
13
+ [self.window addSubview:label];
14
+ [self.window makeKeyAndVisible];
15
+ return YES;
16
+ }
17
+ @end
18
+
19
+ int main(int argc, char *argv[]) {
20
+ @autoreleasepool {
21
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
22
+ }
23
+ }