From 369c8f03db2f6d507697ab2296db5e6f81c8cd1e Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Sat, 27 Jun 2026 17:15:11 +0800
Subject: [PATCH] Reduce SmartStart default categories to thirteen
---
src/build.sh | 93 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 87 insertions(+), 6 deletions(-)
diff --git a/src/build.sh b/src/build.sh
index 1ab51d8..7cd66d7 100644
--- a/src/build.sh
+++ b/src/build.sh
@@ -10,9 +10,85 @@
RESOURCES_DIR="$APP_BUNDLE/Contents/Resources"
SWIFT_DIR="$PROJECT_DIR/Apptag"
INFO_PLIST="$SWIFT_DIR/Info.plist"
+MODULE_CACHE_DIR="${MODULE_CACHE_DIR:-$BUILD_DIR/ModuleCache}"
-SDK_PATH=$(xcrun --sdk macosx --show-sdk-path)
-TARGET="arm64-apple-macosx15.0"
+MACOS_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET:-14.0}"
+TARGET_ARCH="${TARGET_ARCH:-arm64}"
+TARGET="${TARGET_ARCH}-apple-macosx${MACOS_DEPLOYMENT_TARGET}"
+SWIFTC="${SWIFTC:-swiftc}"
+
+select_macos_sdk() {
+ local target="$1"
+ local explicit_sdk="${SDK_PATH:-${SDKROOT:-}}"
+ if [ -n "$explicit_sdk" ]; then
+ if [ ! -d "$explicit_sdk" ]; then
+ echo "❌ Explicit SDK path does not exist: $explicit_sdk" >&2
+ return 1
+ fi
+ echo "$explicit_sdk"
+ return 0
+ fi
+
+ local default_sdk
+ default_sdk="$(xcrun --sdk macosx --show-sdk-path 2>/dev/null || true)"
+ local sdk_candidates
+ sdk_candidates="$(python3 - "$default_sdk" <<'PY'
+import glob
+import os
+import re
+import sys
+
+seen = set()
+candidates = []
+
+def add(path):
+ if not path:
+ return
+ real = os.path.realpath(path)
+ if os.path.isdir(path) and real not in seen:
+ seen.add(real)
+ candidates.append(path)
+
+if len(sys.argv) > 1:
+ add(sys.argv[1])
+
+for path in glob.glob("/Library/Developer/CommandLineTools/SDKs/MacOSX*.sdk"):
+ add(path)
+
+for path in glob.glob("/Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.sdk"):
+ add(path)
+
+def version_key(path):
+ name = os.path.basename(path)
+ match = re.search(r"MacOSX(\d+(?:\.\d+)*)\.sdk$", name)
+ if not match:
+ return ()
+ return tuple(int(part) for part in match.group(1).split("."))
+
+default_real = os.path.realpath(sys.argv[1]) if len(sys.argv) > 1 else ""
+rest = [p for p in candidates if os.path.realpath(p) != default_real]
+rest.sort(key=version_key, reverse=True)
+ordered = [p for p in candidates if os.path.realpath(p) == default_real] + rest
+for path in ordered:
+ print(path)
+PY
+)"
+
+ while IFS= read -r sdk; do
+ [ -n "$sdk" ] || continue
+ if printf 'import Swift\n' | "$SWIFTC" -typecheck -sdk "$sdk" -target "$target" - >/dev/null 2>&1; then
+ echo "$sdk"
+ return 0
+ fi
+ done <<< "$sdk_candidates"
+
+ echo "❌ No installed macOS SDK is compatible with current swiftc for target $target" >&2
+ echo " swiftc: $("$SWIFTC" --version | head -n 1)" >&2
+ echo " default SDK: $default_sdk" >&2
+ return 1
+}
+
+SDK_PATH="$(select_macos_sdk "$TARGET")"
APP_VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$INFO_PLIST")
APP_BUILD="${APP_BUILD:-$(date '+%Y%m%d.%H%M')}"
@@ -23,6 +99,8 @@
fi
echo "==> Packaging $APP_NAME $APP_VERSION ($APP_BUILD)"
+echo "==> Using SDK: $SDK_PATH"
+echo "==> Using Swift compiler: $SWIFTC"
# --- Optional: App Store / Sandbox signing ---
# Set CODESIGN_IDENTITY to your "Apple Distribution" or "Mac Developer" cert name.
@@ -48,13 +126,14 @@
echo "==> Creating bundle structure..."
mkdir -p "$MACOS_DIR"
mkdir -p "$RESOURCES_DIR"
+mkdir -p "$MODULE_CACHE_DIR"
echo "==> Compiling Swift files..."
SWIFT_FILES=()
while IFS= read -r file; do
SWIFT_FILES+=("$file")
done < <(find "$SWIFT_DIR" -name '*.swift' -print | sort)
-swiftc \
+"$SWIFTC" \
-o "$MACOS_DIR/$APP_NAME" \
-framework AppKit \
-framework SwiftUI \
@@ -63,6 +142,7 @@
-lcompression \
-sdk "$SDK_PATH" \
-target "$TARGET" \
+ -module-cache-path "$MODULE_CACHE_DIR" \
-Osize \
"${SWIFT_FILES[@]}"
@@ -72,7 +152,10 @@
echo "==> Copying AppIcon.icns..."
APPICON_SOURCE_DIR="$SWIFT_DIR/Assets.xcassets/AppIcon.appiconset"
-if [ -d "$APPICON_SOURCE_DIR" ]; then
+PREBUILT_APPICON="$PROJECT_DIR/icon-icns.icns"
+if [ -f "$PREBUILT_APPICON" ]; then
+ cp "$PREBUILT_APPICON" "$RESOURCES_DIR/AppIcon.icns"
+elif [ -d "$APPICON_SOURCE_DIR" ]; then
TMP_ICONSET_PARENT="$(mktemp -d -t taglauncher-appicon.XXXXXX)"
TMP_ICONSET="$TMP_ICONSET_PARENT/AppIcon.iconset"
mkdir -p "$TMP_ICONSET"
@@ -97,8 +180,6 @@
done
iconutil -c icns "$TMP_ICONSET" -o "$RESOURCES_DIR/AppIcon.icns"
rm -rf "$TMP_ICONSET_PARENT"
-elif [ -f "$PROJECT_DIR/icon-icns.icns" ]; then
- cp "$PROJECT_DIR/icon-icns.icns" "$RESOURCES_DIR/AppIcon.icns"
elif [ -f "$SWIFT_DIR/AppIcon.iconset/icon_512x512@2x.png" ]; then
iconutil -c icns "$SWIFT_DIR/AppIcon.iconset" -o "$RESOURCES_DIR/AppIcon.icns" 2>/dev/null
else
--
Gitblit v1.9.3