#!/usr/bin/env bash # # launch.sh — Launch the CodeEdit app built by build.sh. # # Works standalone (build.sh does not need to have been sourced). Locates the # .app relative to this script and hands off to `open`. # set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" APP_NAME="CodeEdit.app" # Candidate locations, most-specific first: # 1. $APP_OUTPUT_DIR (if the build was told to publish elsewhere) # 2. next to this script (build.sh's default output location) # 3. the raw Xcode build-products directory (fallback) CANDIDATES=( "${APP_OUTPUT_DIR:-}/$APP_NAME" "$SCRIPT_DIR/$APP_NAME" "$SCRIPT_DIR/DerivedData/Build/Products/Release/$APP_NAME" ) APP_PATH="" for c in "${CANDIDATES[@]}"; do [ -n "$c" ] || continue if [ -d "$c" ]; then APP_PATH="$c" break fi done if [ -z "$APP_PATH" ]; then echo "ERROR: could not find $APP_NAME. Run 'bash build.sh' first." >&2 exit 1 fi echo "Launching $APP_PATH" # CodeEdit is a self-contained .app bundle: all frameworks are embedded under # Contents/Frameworks with @rpath, so no DYLD_* / QT_* runtime variables are # required. `open -W` blocks until the app quits and forwards any extra args. if [ "$#" -gt 0 ]; then exec open -W "$APP_PATH" --args "$@" else exec open -W "$APP_PATH" fi