scripts/build-ios-app.sh

bd275bd1a81b85a03549d5435d6a0bd32c2cbd66
orgstar/scripts/build-ios-app.sh

203 lines · 8820 bytes · executable

  1#!/bin/sh
  2# Builds orgstar.app for the iOS Simulator in .build/ios-app from the OrgstarMobile product,
  3# signed ad hoc. Install with `xcrun simctl install booted .build/ios-app/orgstar.app`.
  4# Usage: scripts/build-ios-app.sh [version]
  5set -eu
  6
  7cd "$(dirname "$0")/.."
  8version="${1:-1.3.1}"
  9app=".build/ios-app/orgstar.app"
 10products=".build/ios/Build/Products/Debug-iphonesimulator"
 11
 12# The entitlements (the app group the share extension leaves captures in) go where the
 13# Simulator reads them, into the binaries.
 14entitlements=scripts/OrgstarMobile.entitlements
 15for scheme in OrgstarMobile OrgstarQuickLook OrgstarShare; do
 16    xcodebuild -scheme "$scheme" -destination 'generic/platform=iOS Simulator' -derivedDataPath .build/ios build -quiet \
 17        CODE_SIGN_ENTITLEMENTS="$PWD/$entitlements"
 18done
 19
 20rm -rf "$app"
 21mkdir -p "$app"
 22cp "$products/OrgstarMobile" "$app/OrgstarMobile"
 23for bundle in "$products"/*.bundle; do
 24    [ -e "$bundle" ] && cp -R "$bundle" "$app/"
 25done
 26
 27cat > "$app/Info.plist" <<PLIST
 28<?xml version="1.0" encoding="UTF-8"?>
 29<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 30<plist version="1.0">
 31<dict>
 32    <key>CFBundleIdentifier</key>
 33    <string>sh.krz.orgstar</string>
 34    <key>CFBundleDevelopmentRegion</key>
 35    <string>en</string>
 36    <key>CFBundleLocalizations</key>
 37    <array><string>en</string><string>de</string><string>fr</string><string>ja</string><string>es</string><string>pt-BR</string></array>
 38    <key>CFBundleName</key>
 39    <string>orgstar</string>
 40    <key>CFBundleDisplayName</key>
 41    <string>orgstar</string>
 42    <key>LSApplicationCategoryType</key>
 43    <string>public.app-category.productivity</string>
 44    <key>CFBundleExecutable</key>
 45    <string>OrgstarMobile</string>
 46    <key>CFBundlePackageType</key>
 47    <string>APPL</string>
 48    <key>CFBundleShortVersionString</key>
 49    <string>${version}</string>
 50    <key>CFBundleVersion</key>
 51    <string>${version}</string>
 52    <key>CFBundleSupportedPlatforms</key>
 53    <array><string>iPhoneSimulator</string></array>
 54    <key>MinimumOSVersion</key>
 55    <string>26.0</string>
 56    <key>NSCameraUsageDescription</key>
 57    <string>Photos you take and documents you scan from the editor are saved with your notes and linked where the caret is.</string>
 58    <key>NSFaceIDUsageDescription</key>
 59    <string>Face ID unlocks the passphrase of encrypted entries you asked orgstar to remember.</string>
 60    <key>NSCalendarsFullAccessUsageDescription</key>
 61    <string>The agenda shows your calendar events alongside your Org entries. orgstar changes your calendars only when you edit an event or add an entry to one.</string>
 62    <key>NSRemindersFullAccessUsageDescription</key>
 63    <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string>
 64    <key>UIDeviceFamily</key>
 65    <array><integer>1</integer><integer>2</integer></array>
 66    <key>UILaunchScreen</key>
 67    <dict/>
 68    <key>UIApplicationSceneManifest</key>
 69    <dict>
 70        <key>UIApplicationSupportsMultipleScenes</key>
 71        <true/>
 72        <key>UISceneConfigurations</key>
 73        <dict>
 74            <key>UIWindowSceneSessionRoleExternalDisplayNonInteractive</key>
 75            <array>
 76                <dict>
 77                    <key>UISceneConfigurationName</key>
 78                    <string>External Display</string>
 79                    <key>UISceneDelegateClassName</key>
 80                    <string>ExternalDisplaySceneDelegate</string>
 81                </dict>
 82            </array>
 83        </dict>
 84    </dict>
 85    <key>UISupportedInterfaceOrientations</key>
 86    <array>
 87        <string>UIInterfaceOrientationPortrait</string>
 88        <string>UIInterfaceOrientationLandscapeLeft</string>
 89        <string>UIInterfaceOrientationLandscapeRight</string>
 90    </array>
 91    <key>UISupportedInterfaceOrientations~ipad</key>
 92    <array>
 93        <string>UIInterfaceOrientationPortrait</string>
 94        <string>UIInterfaceOrientationPortraitUpsideDown</string>
 95        <string>UIInterfaceOrientationLandscapeLeft</string>
 96        <string>UIInterfaceOrientationLandscapeRight</string>
 97    </array>
 98    <!-- public.text, not public.plain-text as on the Mac: iOS previews plain text itself and
 99         never asks the Quick Look extension. -->
100    <key>UTImportedTypeDeclarations</key>
101    <array>
102        <dict>
103            <key>UTTypeIdentifier</key>
104            <string>org.orgmode.org</string>
105            <key>UTTypeDescription</key>
106            <string>Org document</string>
107            <key>UTTypeConformsTo</key>
108            <array><string>public.text</string></array>
109            <key>UTTypeTagSpecification</key>
110            <dict>
111                <key>public.filename-extension</key>
112                <array><string>org</string><string>org_archive</string></array>
113            </dict>
114        </dict>
115    </array>
116    <key>CFBundleURLTypes</key>
117    <array>
118        <dict>
119            <key>CFBundleURLName</key>
120            <string>org-protocol</string>
121            <key>CFBundleURLSchemes</key>
122            <array><string>org-protocol</string></array>
123        </dict>
124    </array>
125    <key>NSUserActivityTypes</key>
126    <array><string>sh.krz.orgstar.editing</string></array>
127</dict>
128</plist>
129PLIST
130
131# App Intents metadata for Shortcuts, from the constant values the build extracted; building
132# a package doesn't run this step itself.
133toolchain="$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain"
134objects=".build/ios/Build/Intermediates.noindex/Orgstar.build/Debug-iphonesimulator/OrgstarMobile-p.build/Objects-normal/arm64"
135work="$(mktemp -d)"
136ls "$PWD/$objects"/*.swiftconstvalues > "$work/constvalues.txt"
137"$toolchain/usr/bin/appintentsmetadataprocessor" --toolchain-dir "$toolchain" --module-name OrgstarMobile \
138    --sdk-root "$(xcrun --sdk iphonesimulator --show-sdk-path)" --xcode-version "$(xcodebuild -version | awk '/Build version/ {print $3}')" \
139    --platform-family iOS --deployment-target 26.0 --bundle-identifier sh.krz.orgstar \
140    --target-triple arm64-apple-ios26.0-simulator --binary-file "$app/OrgstarMobile" --source-file-list "$objects/OrgstarMobile.SwiftFileList" \
141    --swift-const-vals-list "$work/constvalues.txt" --output "$app" --force > /dev/null 2>&1
142
143# The UI's translations, from l10n/Localizable.xcstrings.
144scripts/localize.sh "$app"
145
146appex() { # name, bundle id suffix, extension point, principal class, attributes, entitlements
147    dir="$app/PlugIns/$1.appex"
148    mkdir -p "$dir"
149    cp "$products/$1" "$dir/$1"
150    scripts/localize.sh "$dir"
151    cat > "$dir/Info.plist" <<PLIST
152<?xml version="1.0" encoding="UTF-8"?>
153<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
154<plist version="1.0">
155<dict>
156    <key>CFBundleIdentifier</key>
157    <string>sh.krz.orgstar.$2</string>
158    <key>CFBundleName</key>
159    <string>$1</string>
160    <key>CFBundleDisplayName</key>
161    <string>orgstar</string>
162    <key>CFBundleExecutable</key>
163    <string>$1</string>
164    <key>CFBundlePackageType</key>
165    <string>XPC!</string>
166    <key>CFBundleShortVersionString</key>
167    <string>${version}</string>
168    <key>CFBundleVersion</key>
169    <string>${version}</string>
170    <key>CFBundleSupportedPlatforms</key>
171    <array><string>iPhoneSimulator</string></array>
172    <key>MinimumOSVersion</key>
173    <string>26.0</string>
174    <key>NSExtension</key>
175    <dict>
176        <key>NSExtensionPointIdentifier</key>
177        <string>$3</string>
178        <key>NSExtensionPrincipalClass</key>
179        <string>$4</string>
180        <key>NSExtensionAttributes</key>
181        <dict>$5</dict>
182    </dict>
183</dict>
184</plist>
185PLIST
186    codesign --force --sign - ${6:+--entitlements "$6"} "$dir"
187}
188# Quick Look previews of org files, in Files and wherever else Quick Look shows them.
189appex OrgstarQuickLook quicklook com.apple.quicklook.preview PreviewProvider \
190    "<key>QLSupportedContentTypes</key><array><string>org.orgmode.org</string></array><key>QLIsDataBasedPreview</key><true/>"
191# Capture from the share sheet: a page's link or text.
192appex OrgstarShare share com.apple.share-services ShareViewController \
193    "<key>NSExtensionActivationRule</key><dict><key>NSExtensionActivationSupportsWebURLWithMaxCount</key><integer>1</integer><key>NSExtensionActivationSupportsText</key><true/><key>NSExtensionActivationSupportsImageWithMaxCount</key><integer>10</integer><key>NSExtensionActivationSupportsMovieWithMaxCount</key><integer>10</integer><key>NSExtensionActivationSupportsFileWithMaxCount</key><integer>10</integer></dict>" \
194    "$entitlements"
195
196# The watch app, which a paired watch installs from here.
197scripts/build-watch-app.sh "$version" > /dev/null
198mkdir -p "$app/Watch"
199cp -R .build/watch-app/OrgstarWatch.app "$app/Watch/"
200
201codesign --force --sign - --entitlements "$entitlements" "$app"
202rm -rf "$work"
203echo "$app"
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form