#!/bin/sh # Builds orgstar.app for the iOS Simulator in .build/ios-app from the OrgstarMobile product, # signed ad hoc. Install with `xcrun simctl install booted .build/ios-app/orgstar.app`. # Usage: scripts/build-ios-app.sh [version] set -eu cd "$(dirname "$0")/.." version="${1:-0.1.0}" app=".build/ios-app/orgstar.app" products=".build/ios/Build/Products/Debug-iphonesimulator" # The entitlements (the app group the share extension leaves captures in) go where the # Simulator reads them, into the binaries. entitlements=scripts/OrgstarMobile.entitlements for scheme in OrgstarMobile OrgstarQuickLook OrgstarShare; do xcodebuild -scheme "$scheme" -destination 'generic/platform=iOS Simulator' -derivedDataPath .build/ios build -quiet \ CODE_SIGN_ENTITLEMENTS="$PWD/$entitlements" done rm -rf "$app" mkdir -p "$app" cp "$products/OrgstarMobile" "$app/OrgstarMobile" for bundle in "$products"/*.bundle; do [ -e "$bundle" ] && cp -R "$bundle" "$app/" done cat > "$app/Info.plist" < CFBundleIdentifier sh.krz.orgstar CFBundleName orgstar CFBundleDisplayName orgstar LSApplicationCategoryType public.app-category.productivity CFBundleExecutable OrgstarMobile CFBundlePackageType APPL CFBundleShortVersionString ${version} CFBundleVersion ${version} CFBundleSupportedPlatforms iPhoneSimulator MinimumOSVersion 26.0 NSFaceIDUsageDescription Face ID unlocks the passphrase of encrypted entries you asked orgstar to remember. NSCalendarsFullAccessUsageDescription The agenda shows your calendar events alongside your Org entries. orgstar only reads them. UIDeviceFamily 12 UILaunchScreen UIApplicationSceneManifest UIApplicationSupportsMultipleScenes UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UTImportedTypeDeclarations UTTypeIdentifier org.orgmode.org UTTypeDescription Org document UTTypeConformsTo public.text UTTypeTagSpecification public.filename-extension orgorg_archive CFBundleURLTypes CFBundleURLName org-protocol CFBundleURLSchemes org-protocol PLIST # App Intents metadata for Shortcuts, from the constant values the build extracted; building # a package doesn't run this step itself. toolchain="$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain" objects=".build/ios/Build/Intermediates.noindex/Orgstar.build/Debug-iphonesimulator/OrgstarMobile-p.build/Objects-normal/arm64" work="$(mktemp -d)" ls "$PWD/$objects"/*.swiftconstvalues > "$work/constvalues.txt" "$toolchain/usr/bin/appintentsmetadataprocessor" --toolchain-dir "$toolchain" --module-name OrgstarMobile \ --sdk-root "$(xcrun --sdk iphonesimulator --show-sdk-path)" --xcode-version "$(xcodebuild -version | awk '/Build version/ {print $3}')" \ --platform-family iOS --deployment-target 26.0 --bundle-identifier sh.krz.orgstar \ --target-triple arm64-apple-ios26.0-simulator --binary-file "$app/OrgstarMobile" --source-file-list "$objects/OrgstarMobile.SwiftFileList" \ --swift-const-vals-list "$work/constvalues.txt" --output "$app" --force > /dev/null 2>&1 appex() { # name, bundle id suffix, extension point, principal class, attributes, entitlements dir="$app/PlugIns/$1.appex" mkdir -p "$dir" cp "$products/$1" "$dir/$1" cat > "$dir/Info.plist" < CFBundleIdentifier sh.krz.orgstar.$2 CFBundleName $1 CFBundleDisplayName orgstar CFBundleExecutable $1 CFBundlePackageType XPC! CFBundleShortVersionString ${version} CFBundleVersion ${version} CFBundleSupportedPlatforms iPhoneSimulator MinimumOSVersion 26.0 NSExtension NSExtensionPointIdentifier $3 NSExtensionPrincipalClass $4 NSExtensionAttributes $5 PLIST codesign --force --sign - ${6:+--entitlements "$6"} "$dir" } # Quick Look previews of org files, in Files and wherever else Quick Look shows them. appex OrgstarQuickLook quicklook com.apple.quicklook.preview PreviewProvider \ "QLSupportedContentTypesorg.orgmode.orgQLIsDataBasedPreview" # Capture from the share sheet: a page's link or text. appex OrgstarShare share com.apple.share-services ShareViewController \ "NSExtensionActivationRuleNSExtensionActivationSupportsWebURLWithMaxCount1NSExtensionActivationSupportsTextNSExtensionActivationSupportsImageWithMaxCount10NSExtensionActivationSupportsMovieWithMaxCount10NSExtensionActivationSupportsFileWithMaxCount10" \ "$entitlements" codesign --force --sign - --entitlements "$entitlements" "$app" rm -rf "$work" echo "$app"