Skip to content

Commit d4558fa

Browse files
Add release packaging
1 parent 6931328 commit d4558fa

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
.build/
55
.swiftpm/
66
Package.resolved
7+
dist/
78

89
# Xcode
910
DerivedData/

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ Run it directly with SwiftPM:
4343
swift run
4444
```
4545

46+
Create an unsigned release `.app` bundle and zip:
47+
48+
```bash
49+
scripts/package-app.sh
50+
```
51+
4652
## Dependency Setup
4753

4854
Khons can install most runtime dependencies from the app UI, but you can also prepare them manually.
@@ -85,6 +91,7 @@ swift run
8591
- If `idevice_id` or `idevicesetlocation` are missing, install `libimobiledevice`.
8692
- If no devices appear, reconnect the phone, unlock it, trust the Mac, and retry.
8793
- Modern iOS simulation relies on Apple developer services exposed through `pymobiledevice3`, so local environment setup matters.
94+
- The packaged `.app` generated by `scripts/package-app.sh` is unsigned.
8895

8996
## License Clarification
9097

scripts/package-app.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/zsh
2+
3+
set -euo pipefail
4+
5+
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
6+
APP_NAME="Khons"
7+
VERSION="0.0.1"
8+
BUILD_NUMBER="001"
9+
BUILD_DIR="$ROOT_DIR/.build/arm64-apple-macosx/release"
10+
DIST_DIR="$ROOT_DIR/dist"
11+
APP_DIR="$DIST_DIR/$APP_NAME.app"
12+
CONTENTS_DIR="$APP_DIR/Contents"
13+
MACOS_DIR="$CONTENTS_DIR/MacOS"
14+
RESOURCES_DIR="$CONTENTS_DIR/Resources"
15+
MODULE_CACHE_DIR="$ROOT_DIR/.build/module-cache"
16+
17+
cd "$ROOT_DIR"
18+
19+
if [[ ! -x "$BUILD_DIR/$APP_NAME" ]]; then
20+
mkdir -p "$MODULE_CACHE_DIR"
21+
export CLANG_MODULE_CACHE_PATH="$MODULE_CACHE_DIR"
22+
export SWIFTPM_MODULECACHE_OVERRIDE="$MODULE_CACHE_DIR"
23+
swift build -c release
24+
fi
25+
26+
rm -rf "$APP_DIR"
27+
mkdir -p "$MACOS_DIR" "$RESOURCES_DIR"
28+
29+
cp "$BUILD_DIR/$APP_NAME" "$MACOS_DIR/$APP_NAME"
30+
cp "$ROOT_DIR/Resources/Preview.png" "$RESOURCES_DIR/Preview.png"
31+
32+
cat > "$CONTENTS_DIR/Info.plist" <<EOF
33+
<?xml version="1.0" encoding="UTF-8"?>
34+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
35+
<plist version="1.0">
36+
<dict>
37+
<key>CFBundleDevelopmentRegion</key>
38+
<string>en</string>
39+
<key>CFBundleExecutable</key>
40+
<string>$APP_NAME</string>
41+
<key>CFBundleIconFile</key>
42+
<string>Preview</string>
43+
<key>CFBundleIdentifier</key>
44+
<string>com.stacknode.khons</string>
45+
<key>CFBundleInfoDictionaryVersion</key>
46+
<string>6.0</string>
47+
<key>CFBundleName</key>
48+
<string>$APP_NAME</string>
49+
<key>CFBundlePackageType</key>
50+
<string>APPL</string>
51+
<key>CFBundleShortVersionString</key>
52+
<string>$VERSION</string>
53+
<key>CFBundleVersion</key>
54+
<string>$BUILD_NUMBER</string>
55+
<key>LSMinimumSystemVersion</key>
56+
<string>14.0</string>
57+
<key>NSHighResolutionCapable</key>
58+
<true/>
59+
</dict>
60+
</plist>
61+
EOF
62+
63+
echo -n "APPL????" > "$CONTENTS_DIR/PkgInfo"
64+
65+
ditto -c -k --sequesterRsrc --keepParent "$APP_DIR" "$DIST_DIR/$APP_NAME-$BUILD_NUMBER.zip"
66+
67+
echo "Created:"
68+
echo " $APP_DIR"
69+
echo " $DIST_DIR/$APP_NAME-$BUILD_NUMBER.zip"

0 commit comments

Comments
 (0)