scripts/build-watch-app.sh

98 lines · 3618 bytes · executable

 1#!/bin/sh
 2# Builds OrgstarWatch.app, with its complications, for the watchOS Simulator in
 3# .build/watch-app from the OrgstarWatch and OrgstarWatchWidgets products, signed ad hoc.
 4# scripts/build-ios-app.sh embeds it in the iOS app; install it on a paired watch simulator
 5# with `xcrun simctl install <watch> .build/watch-app/OrgstarWatch.app`.
 6# Usage: scripts/build-watch-app.sh [version]
 7set -eu
 8
 9cd "$(dirname "$0")/.."
10version="${1:-0.9.0}"
11app=".build/watch-app/OrgstarWatch.app"
12products=".build/watch/Build/Products/Debug-watchsimulator"
13# The app group the complications read the agenda from, on the watch.
14entitlements=scripts/OrgstarMobile.entitlements
15
16for scheme in OrgstarWatch OrgstarWatchWidgets; do
17    xcodebuild -scheme "$scheme" -destination 'generic/platform=watchOS Simulator' -derivedDataPath .build/watch build -quiet \
18        CODE_SIGN_ENTITLEMENTS="$PWD/$entitlements"
19done
20
21rm -rf "$app"
22mkdir -p "$app/PlugIns/OrgstarWatchWidgets.appex"
23cp "$products/OrgstarWatch" "$app/OrgstarWatch"
24scripts/localize.sh "$app"
25cat > "$app/Info.plist" <<PLIST
26<?xml version="1.0" encoding="UTF-8"?>
27<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
28<plist version="1.0">
29<dict>
30    <key>CFBundleIdentifier</key>
31    <string>sh.krz.orgstar.watchkitapp</string>
32    <key>CFBundleDevelopmentRegion</key>
33    <string>en</string>
34    <key>CFBundleLocalizations</key>
35    <array><string>en</string><string>de</string><string>fr</string><string>ja</string><string>es</string><string>pt-BR</string></array>
36    <key>CFBundleName</key>
37    <string>orgstar</string>
38    <key>CFBundleDisplayName</key>
39    <string>orgstar</string>
40    <key>CFBundleExecutable</key>
41    <string>OrgstarWatch</string>
42    <key>CFBundlePackageType</key>
43    <string>APPL</string>
44    <key>CFBundleShortVersionString</key>
45    <string>${version}</string>
46    <key>CFBundleVersion</key>
47    <string>${version}</string>
48    <key>CFBundleSupportedPlatforms</key>
49    <array><string>WatchSimulator</string></array>
50    <key>MinimumOSVersion</key>
51    <string>26.0</string>
52    <key>UIDeviceFamily</key>
53    <array><integer>4</integer></array>
54    <key>WKApplication</key>
55    <true/>
56    <key>WKCompanionAppBundleIdentifier</key>
57    <string>sh.krz.orgstar</string>
58</dict>
59</plist>
60PLIST
61
62dir="$app/PlugIns/OrgstarWatchWidgets.appex"
63cp "$products/OrgstarWatchWidgets" "$dir/OrgstarWatchWidgets"
64scripts/localize.sh "$dir"
65cat > "$dir/Info.plist" <<PLIST
66<?xml version="1.0" encoding="UTF-8"?>
67<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
68<plist version="1.0">
69<dict>
70    <key>CFBundleIdentifier</key>
71    <string>sh.krz.orgstar.watchkitapp.widgets</string>
72    <key>CFBundleName</key>
73    <string>OrgstarWatchWidgets</string>
74    <key>CFBundleDisplayName</key>
75    <string>orgstar</string>
76    <key>CFBundleExecutable</key>
77    <string>OrgstarWatchWidgets</string>
78    <key>CFBundlePackageType</key>
79    <string>XPC!</string>
80    <key>CFBundleShortVersionString</key>
81    <string>${version}</string>
82    <key>CFBundleVersion</key>
83    <string>${version}</string>
84    <key>CFBundleSupportedPlatforms</key>
85    <array><string>WatchSimulator</string></array>
86    <key>MinimumOSVersion</key>
87    <string>26.0</string>
88    <key>NSExtension</key>
89    <dict>
90        <key>NSExtensionPointIdentifier</key>
91        <string>com.apple.widgetkit-extension</string>
92    </dict>
93</dict>
94</plist>
95PLIST
96codesign --force --sign - --entitlements "$entitlements" "$dir"
97codesign --force --sign - --entitlements "$entitlements" "$app"
98echo "$app"