Cotton code
60 lines · 2.9 KB · ShellRaw
#!/usr/bin/env bash# Called only by ui-tests-stub.sh --home-preview, inside its private workspace# and build lock: builds the synthetic Home preview (HomePreviewApp.swift) for# the iOS simulator, installs it on the caller's own booted simulator and# launches it. The simulator is the caller's; it is never created, erased or# deleted here. Extra arguments are passed to the app (-home-board, -home-tiles).set -euo pipefailDIR="$1"; SIM="$2"; REPO="$3"; shift 3mkdir -p "$DIR/home-preview"cp "$REPO/scripts/home-preview/HomePreviewApp.swift" "$DIR/home-preview/HomePreviewApp.swift"# The phrase parser's Swift port is test support, never app code: the preview# compiles it beside itself, as the tests do.cp "$REPO/apps/cotton/Tests/CottonUITests/Support/FixturePhraseParser.swift" "$DIR/home-preview/FixturePhraseParser.swift"cat > "$DIR/home-preview/project.yml" <<'YAML'name: CottonHomePreviewoptions:  bundleIdPrefix: com.cottondbpackages:  cotton:    path: ../apps/cottontargets:  CottonHomePreview:    type: application    platform: iOS    deploymentTarget: '26.0'    sources: [HomePreviewApp.swift, FixturePhraseParser.swift]    dependencies:      - package: cotton        product: CottonUI    settings:      base:        PRODUCT_BUNDLE_IDENTIFIER: com.cottondb.homepreview        GENERATE_INFOPLIST_FILE: YES        INFOPLIST_KEY_UILaunchScreen_Generation: YES        INFOPLIST_KEY_UIApplicationSceneManifest_Generation: YES        INFOPLIST_KEY_NSMicrophoneUsageDescription: The record button listens to what you say.        INFOPLIST_KEY_NSSpeechRecognitionUsageDescription: What you say becomes words on the device.        INFOPLIST_KEY_CADisableMinimumFrameDurationOnPhone: YES        SWIFT_VERSION: '6.0'        SWIFT_OPTIMIZATION_LEVEL: '-O'        ENABLE_TESTABILITY: YES        CODE_SIGNING_ALLOWED: NOYAML(cd "$DIR/home-preview" && xcodegen generate >/dev/null)# shellcheck source=../lib/derived-data.sh. "$REPO/scripts/lib/derived-data.sh"DERIVED="$(cotton_derived_data)/home-preview"# Inside a lane's seatbelt Xcode's own sandboxes cannot start; the lane# policy's flags turn them off (scripts/lib/mac_disk_policy.py, lane_args).NO_SANDBOX=()[ "${COTTON_LANE_SANDBOXED:-}" = 1 ] && NO_SANDBOX=(-IDEPackageSupportDisableManifestSandbox=YES  -IDEPackageSupportDisablePluginExecutionSandbox=YES ENABLE_USER_SCRIPT_SANDBOXING=NO  'OTHER_SWIFT_FLAGS=$(inherited) -disable-sandbox')xcodebuild build -project "$DIR/home-preview/CottonHomePreview.xcodeproj" -scheme CottonHomePreview \  -destination "platform=iOS Simulator,id=$SIM" -derivedDataPath "$DERIVED" \  SWIFT_OPTIMIZATION_LEVEL=-O ENABLE_TESTABILITY=YES CODE_SIGNING_ALLOWED=NO -quiet ${NO_SANDBOX[@]+"${NO_SANDBOX[@]}"}APP="$DERIVED/Build/Products/Debug-iphonesimulator/CottonHomePreview.app"xcrun simctl install "$SIM" "$APP"xcrun simctl terminate "$SIM" com.cottondb.homepreview >/dev/null 2>&1 || truexcrun simctl launch "$SIM" com.cottondb.homepreview "$@"