-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·82 lines (73 loc) · 2.49 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·82 lines (73 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# 构建 MiniLink.app:swift build → 组装 .app 包 → ad-hoc 签名
set -euo pipefail
cd "$(dirname "$0")"
select_compatible_sdk() {
# 尊重调用者明确指定的 SDK。
if [[ -n "${SDKROOT:-}" ]]; then
return
fi
local target_arch
target_arch="$(uname -m)"
# Command Line Tools 偶尔会出现 swiftc 与默认 SDK 补丁版本不同步。
# 先做一个轻量 SwiftUI 类型检查;失败时自动选择已安装且兼容的版本化 SDK。
if printf 'import SwiftUI\n' | swiftc -typecheck \
-target "${target_arch}-apple-macosx14.0" - >/dev/null 2>&1; then
return
fi
local sdk
for sdk in /Library/Developer/CommandLineTools/SDKs/MacOSX[0-9]*.sdk; do
[[ -d "$sdk" ]] || continue
if printf 'import SwiftUI\n' | swiftc -typecheck \
-target "${target_arch}-apple-macosx14.0" -sdk "$sdk" - >/dev/null 2>&1; then
export SDKROOT="$sdk"
echo "ℹ️ 默认 SDK 与 Swift 编译器不兼容,改用:$SDKROOT"
return
fi
done
echo "❌ 找不到与当前 Swift 编译器兼容的 macOS SDK" >&2
exit 1
}
select_compatible_sdk
swift build -c release
APP="build/MiniLink.app"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp .build/release/MiniLink "$APP/Contents/MacOS/MiniLink"
cp AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
cat > "$APP/Contents/Info.plist" <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>MiniLink</string>
<key>CFBundleIdentifier</key>
<string>com.ethan.MiniLink</string>
<key>CFBundleName</key>
<string>MiniLink</string>
<key>CFBundleDisplayName</key>
<string>MiniLink</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.3</string>
<key>CFBundleVersion</key>
<string>7</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>LSMinimumSystemVersion</key>
<string>14.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSAppleEventsUsageDescription</key>
<string>MiniLink 需要控制「终端」来打开 SSH 连接。</string>
</dict>
</plist>
EOF
codesign --force --sign - "$APP"
echo "✅ 构建完成:$PWD/$APP"
echo " 启动:open $APP"
echo " 建议拖入 /Applications 长期使用(开机自启需要)"