#!/bin/sh # Builds OrgstarWatch.app, with its complications, for the watchOS Simulator in # .build/watch-app from the OrgstarWatch and OrgstarWatchWidgets products, signed ad hoc. # scripts/build-ios-app.sh embeds it in the iOS app; install it on a paired watch simulator # with `xcrun simctl install .build/watch-app/OrgstarWatch.app`. # Usage: scripts/build-watch-app.sh [version] set -eu cd "$(dirname "$0")/.." version="${1:-0.7.0}" app=".build/watch-app/OrgstarWatch.app" products=".build/watch/Build/Products/Debug-watchsimulator" # The app group the complications read the agenda from, on the watch. entitlements=scripts/OrgstarMobile.entitlements for scheme in OrgstarWatch OrgstarWatchWidgets; do xcodebuild -scheme "$scheme" -destination 'generic/platform=watchOS Simulator' -derivedDataPath .build/watch build -quiet \ CODE_SIGN_ENTITLEMENTS="$PWD/$entitlements" done rm -rf "$app" mkdir -p "$app/PlugIns/OrgstarWatchWidgets.appex" cp "$products/OrgstarWatch" "$app/OrgstarWatch" scripts/localize.sh "$app" cat > "$app/Info.plist" < CFBundleIdentifier sh.krz.orgstar.watchkitapp CFBundleDevelopmentRegion en CFBundleLocalizations ende CFBundleName orgstar CFBundleDisplayName orgstar CFBundleExecutable OrgstarWatch CFBundlePackageType APPL CFBundleShortVersionString ${version} CFBundleVersion ${version} CFBundleSupportedPlatforms WatchSimulator MinimumOSVersion 26.0 UIDeviceFamily 4 WKApplication WKCompanionAppBundleIdentifier sh.krz.orgstar PLIST dir="$app/PlugIns/OrgstarWatchWidgets.appex" cp "$products/OrgstarWatchWidgets" "$dir/OrgstarWatchWidgets" scripts/localize.sh "$dir" cat > "$dir/Info.plist" < CFBundleIdentifier sh.krz.orgstar.watchkitapp.widgets CFBundleName OrgstarWatchWidgets CFBundleDisplayName orgstar CFBundleExecutable OrgstarWatchWidgets CFBundlePackageType XPC! CFBundleShortVersionString ${version} CFBundleVersion ${version} CFBundleSupportedPlatforms WatchSimulator MinimumOSVersion 26.0 NSExtension NSExtensionPointIdentifier com.apple.widgetkit-extension PLIST codesign --force --sign - --entitlements "$entitlements" "$dir" codesign --force --sign - --entitlements "$entitlements" "$app" echo "$app"