@@ -6,10 +6,12 @@ set -euo pipefail
66# ---------------------------------------------------------------------------
77if [[ " ${1:- } " == " --bundle" ]]; then
88 APP_NAME=" DeployQA"
9- APP_DIR=" ${APP_NAME} .app"
9+ SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
10+ BUILD_DIR=" ${SCRIPT_DIR} /build"
11+ APP_DIR=" ${BUILD_DIR} /${APP_NAME} .app"
1012 MACOS_DIR=" ${APP_DIR} /Contents/MacOS"
1113 RESOURCES_DIR=" ${APP_DIR} /Contents/Resources"
12- SCRIPT_PATH=" $( cd " $( dirname " $0 " ) " && pwd ) /$( basename " $0 " ) "
14+ SCRIPT_PATH=" ${SCRIPT_DIR} /$( basename " $0 " ) "
1315
1416 echo " Building $APP_NAME ..."
1517
@@ -21,7 +23,7 @@ if [[ "${1:-}" == "--bundle" ]]; then
2123 chmod +x " $RESOURCES_DIR /deploy-qa.sh"
2224
2325 # 3. Write the SwiftUI code to a temporary file
24- cat << 'SWIFT_EOF ' > DeployApp.swift
26+ cat << 'SWIFT_EOF ' > "${BUILD_DIR}/ DeployApp.swift"
2527import SwiftUI
2628import AppKit
2729
@@ -244,8 +246,8 @@ struct SettingsView: View {
244246SWIFT_EOF
245247
246248 # 4. Compile the Swift code into the app bundle executable
247- swiftc DeployApp.swift -parse-as-library -o " $MACOS_DIR /$APP_NAME " || { echo " Compilation failed! Aborting." ; rm DeployApp.swift; exit 1; }
248- rm DeployApp.swift
249+ swiftc " ${BUILD_DIR} / DeployApp.swift" -parse-as-library -o " $MACOS_DIR /$APP_NAME " || { echo " Compilation failed! Aborting." ; rm " ${BUILD_DIR} / DeployApp.swift" ; exit 1; }
250+ rm " ${BUILD_DIR} / DeployApp.swift"
249251
250252 # 5. Create an Info.plist so macOS recognizes it as a real GUI application
251253 cat << 'PLIST_EOF ' > "${APP_DIR}/Contents/Info.plist"
@@ -270,9 +272,9 @@ SWIFT_EOF
270272PLIST_EOF
271273
272274 # 6. Zip it for distribution
273- zip -r -q " ${APP_NAME} .zip" " ${APP_DIR} "
275+ (cd " ${BUILD_DIR} " && zip -r -q " ${APP_NAME} .zip" " ${APP_NAME} .app " )
274276
275- echo " Done! You can now send ${APP_NAME} .zip to the QA team."
277+ echo " Done! You can now send scripts/build/ ${APP_NAME} .zip to the QA team."
276278 exit 0
277279fi
278280
0 commit comments