Repository navigation
Expand file tree
/
Copy pathbuild.command
More file actions
executable file
·41 lines (39 loc) · 1.97 KB
/
Copy pathbuild.command
File metadata and controls
executable file
·41 lines (39 loc) · 1.97 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
#!/bin/zsh
set -eu
cd "${0:A:h}"
APP="$PWD/LocalWatch.app"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
# macOS 27 SDK 把 SwiftUI 的 @State 改成了宏,宏插件只随完整 Xcode 提供。
# 只装 Command Line Tools 的机器上自动退回仍可直接编译的 SDK。
SDK_ROOT="$(xcode-select -p)/SDKs"
SDK_PATH="$(xcrun --show-sdk-path)"
if grep -q 'macro State' "$SDK_PATH/System/Library/Frameworks/SwiftUICore.framework/Versions/A/Modules/SwiftUICore.swiftmodule/arm64e-apple-macos.swiftinterface" 2>/dev/null; then
for candidate in "$SDK_ROOT"/MacOSX*.sdk; do
if ! grep -q 'macro State' "$candidate/System/Library/Frameworks/SwiftUICore.framework/Versions/A/Modules/SwiftUICore.swiftmodule/arm64e-apple-macos.swiftinterface" 2>/dev/null; then
SDK_PATH="$candidate"
fi
done
echo "使用 SDK: $SDK_PATH"
fi
swiftc -Osize -whole-module-optimization -parse-as-library -target arm64-apple-macosx26.0 -sdk "$SDK_PATH" Source/Monitor.swift Source/App.swift -Xlinker -dead_strip -o "$APP/Contents/MacOS/LocalWatch"
strip -x "$APP/Contents/MacOS/LocalWatch"
cat > "$APP/Contents/Info.plist" <<'PLIST'
<?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>LocalWatch</string>
<key>CFBundleIdentifier</key><string>local.ethan.LocalWatch</string>
<key>CFBundleName</key><string>LocalWatch</string>
<key>CFBundleDisplayName</key><string>LocalWatch</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>1.1.0</string>
<key>CFBundleVersion</key><string>2</string>
<key>LSMinimumSystemVersion</key><string>26.0</string>
<key>LSUIElement</key><true/>
<key>NSHighResolutionCapable</key><true/>
<key>CFBundleIconFile</key><string>AppIcon</string>
</dict></plist>
PLIST
cp Source/AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
codesign --force --deep --sign - "$APP"
echo "Built: $APP"