Skip to content

Latest commit

 

History

History
157 lines (131 loc) · 12.1 KB

README.md

File metadata and controls

157 lines (131 loc) · 12.1 KB

Mainloop for iOS

An iPhone app for Mainloop's owner: the web app in a native shell that holds the device's keys. See docs/specs/ios-app.md for what it does today and what is planned.

Layout

Path What it is
project.yml XcodeGen spec, the source of truth. The generated Mainloop.xcodeproj, App/Info.plist and App/Mainloop.entitlements are gitignored.
Config/Mainloop.xcconfig Placeholder bundle ID and origin, and the APNs environment per configuration. Includes Config/Local.xcconfig if it exists.
App/ The shell: first run, the web view and its message handler, the approval sheet and This iPhone, in the web's theme.
Tests/ App tests, run on the simulator.
Packages/MainloopKit Everything that doesn't need UIKit: MainloopAPI (the generated client) and MainloopCore (keys, signing, the approval flow, the shell's rules, the palette). Its tests run on macOS with swift test.
Packages/MainloopKit/.../Generated The Swift client generated from api/openapi.yaml. Do not edit; run scripts/generate-api.sh.
Packages/APIGen Pins swift-openapi-generator, and PrepareContract, which rewrites a temporary copy of the contract into a form the generator reads (nullable anyOf: [X, null] becomes an optional X; integer bounds beyond Int64 are dropped).
scripts/generate-api.sh Regenerates the client. Add an operation to Packages/APIGen/openapi-generator-config.yaml first.
scripts/ci.sh What CI runs: regenerate the client (a stale committed copy is a warning on pull requests and a failure on main, with a patch artifact; see AGENTS.md), swift test, then the simulator build and tests.
Design/make-app-icon.py Draws the app icon from the web's mark (standard library only).

Build

Requires Xcode 27.1 or later (the iOS 27.1 SDK is what lays the app out for iPhone Duo) and XcodeGen. CI runs on GitHub's xcode-27 image.

ios/scripts/ci.sh                                      # everything CI runs
swift test --package-path ios/Packages/MainloopKit     # models and fixtures only, no simulator

By hand:

cd ios
xcodegen generate
open Mainloop.xcodeproj

The app builds with the placeholder origin and says it names no server. To run it on a phone, copy Config/Local.xcconfig.example to Config/Local.xcconfig and set your team ID, bundle ID and Mainloop origin. Nothing in Local.xcconfig is committed. To sign in, also set the Pocket ID issuer and the app's OIDC client: a public client (PKCE, no secret) with the redirect URI mainloop-ios://oauth/callback, whose id the server lists in MAINLOOP_AUTH_DEVICE_CLIENT_ID (see docs/specs/devices.md).

Notifications

Not yet proven on a phone. The app target carries two entitlements, generated by XcodeGen into App/Mainloop.entitlements: aps-environment and Time Sensitive Notifications. To sign it:

  • The App ID (your bundle ID) needs the Push Notifications and Time Sensitive Notifications capabilities in the Apple Developer portal; automatic signing then puts them in the provisioning profile.
  • MAINLOOP_APNS_ENVIRONMENT sets aps-environment and is sent to the server with the device token. It defaults to development (the APNs sandbox) for Debug, which is what a build run from Xcode uses, and production for Release (TestFlight, App Store). Set it in Local.xcconfig only to override both.
  • The server needs an APNs key for the same team and bundle ID (see docs/specs/push-notifications.md). A sandbox token works only with the sandbox endpoint.

CI builds for the simulator with no team or provisioning profile, which these entitlements don't need there.

iPhone Duo

Built with the iOS 27.1 SDK or later, the app fills both of iPhone Duo's displays: the outer one (466 × 678 points) and the inner one (669 × 951, either way up), where the status bar is a column on the right edge and leaves a right-hand safe-area inset that lasts for the whole scene.

  • No device checks. The app reads no UIScreen.main, interface orientation, idiom or device size; layouts follow the space they get. Xcode's app resizability skill found none of its target APIs. Its prerequisites hold: a launch screen (UILaunchScreen), no UIRequiresFullScreen, the SwiftUI scene lifecycle. UISupportedInterfaceOrientations lists portrait and both landscapes; the inner display ignores the list.
  • Native screens (first run, the approval sheet, This iPhone) stay in SwiftUI's safe area and cap their content's width (first run at 560 points), so they read the same in every pose.
  • The web view runs edge to edge (ignoresSafeArea, and the scroll view adds no insets). The page declares viewport-fit=cover and pads itself with env(safe-area-inset-*), including the status bar's column on the right. The web app shows its desktop layout (sidebar and page) on a window at least 640 px on both sides, which is the inner display, and its phone layout on the outer one (layout).
  • To try it: the iPhone Duo simulator (Xcode 27.1 or later). Opening and closing it, and resizing a scene, are in Device Hub's window. simctl io <device> screenConfig only powers a display or changes its mode. Device Hub's resizable simulator and iPhone Mirroring (resized) are Apple's other two ways to test.

The App Store's iPhone Duo badge

From Apple's Prepare for iPhone Duo page (read in November 2026). Check it again before submitting.

  • The badge shows on the product page when the version has iPhone Duo screenshots in App Store Connect.
  • Sizes: the outer display at 1398 × 2034 (portrait) or 2034 × 1398 (landscape); the inner display at 2007 × 2853 or 2853 × 2007. PNG or JPEG, no transparency, up to 10 per size.
  • From April 2027 an app built with the iOS 27.1 SDK or later can't be submitted without them.
  • Featuring: nominate the version in App Store Connect (Featuring Nominations) and say in Helpful details that it is optimised for iPhone Duo in every pose.
  • Screenshots use fictional data only: the web app's fixtures (VITE_MSW=1, ?seed=review; see web/src/test/msw/review-seed.ts) or a disposable server with made-up records. simctl io <device> screenshot --display=<name> writes a display at its native size; simctl io <device> enumerate names the displays.

Release

.github/workflows/ios-release.yml archives the app and uploads it to TestFlight. It is a short caller of the reusable workflow ios-testflight.yml in oldsj/workflows (pinned by commit; that repository's README describes every input and check). A first upload from main proved it.

  • Triggers: workflow_dispatch (the version in project.yml) and a pushed tag ios-v<version>, such as ios-v0.2.0, which sets the version. Both must be on main; the workflow refuses anything else. Never on a pull request: this is a public repository, and a pull request's workflow must never reach a signing secret.
  • GitHub-hosted runner (xcode-27), as for CI. Never self-hosted.
  • Approval: the called job runs in the GitHub environment testflight, which holds the secrets and is set to require the owner's approval, so every upload waits for it. The caller passes secrets: inherit, the only way an environment's secrets reach a reusable workflow.
  • Signing without certificates in the tree: an App Store Connect API key (App Manager role) with xcodebuild -allowProvisioningUpdates -authenticationKeyPath/-ID/-IssuerID. Xcode creates and uses the cloud-managed distribution certificate and profile itself, so no certificate, profile or keychain exists in the repository or in a secret. The key is written to the runner's temporary directory and deleted when the job ends. If Apple refuses cloud signing to that role ("Cloud signing permission error"), create the key with the Admin role instead.
  • Upload: xcodebuild -exportArchive with destination: upload sends the build to App Store Connect with the same key. A failed upload fails the job.
  • Build number: the run number (github.run_number), so every upload is unique. Re-running a failed run keeps its number: start a new run after a build was uploaded.
  • Configuration: the bundle ID (as MAINLOOP_BUNDLE_ID), team ID and the IOS_XCCONFIG lines (Mainloop origin, Pocket ID issuer and client) are written to Config/Local.xcconfig for the job (nothing is committed). The build is Release, so MAINLOOP_APNS_ENVIRONMENT is production, which the archive check asserts.
  • Fails fast: a missing or malformed secret or variable fails the first step with the list of what is missing; the archive check fails before the upload when the app supports iPad but declares fewer than all four orientations (App Store Connect's multitasking rule); the workflow cannot finish green without an upload.
  • Orientations: project.yml declares all four, although the app is iPhone first. The target's effective TARGETED_DEVICE_FAMILY is 1,2 (XcodeGen's iOS preset on the target beats the project-level 1), so Apple applies the iPad rule to it.
Where Name
testflight secrets ASC_KEY_ID, ASC_ISSUER_ID, ASC_KEY_P8 (the file's contents), APPLE_TEAM_ID
testflight variables (no secret) IOS_BUNDLE_ID; IOS_XCCONFIG, lines MAINLOOP_ORIGIN, MAINLOOP_OIDC_ISSUER, MAINLOOP_OIDC_CLIENT_ID (KEY = value)

Before the first run: an App ID with Push Notifications and Time Sensitive Notifications, an App Store Connect app record for the same bundle ID, and the API key. The server's APNs key is separate (see Notifications). Screenshots stay a manual upload until the screens settle.

Rules

  • The API is called only through the generated client, as in web/.
  • Fixtures, previews and screenshots use fictional data only.
  • The page in the web view never gets a key, a signature or the session's token; anything signed is done natively (docs/specs/ios-app.md).
  • No signing material in the tree or in CI logs; CI builds unsigned.