diff --git a/apps/swift-ios/README.md b/apps/swift-ios/README.md index 8b62fd529c..62265706db 100644 --- a/apps/swift-ios/README.md +++ b/apps/swift-ios/README.md @@ -1,13 +1,22 @@ -# T3 Code for iOS +# T3 Code (SwiftUI) -A dependency-free, native SwiftUI client for T3 Code. The project targets iOS 17 -and later on iPhone and iPad. +A native SwiftUI client for T3 Code. The project targets iOS 17 and later on +iPhone and iPad. It has its own bundle identifier and can be installed beside the +React Native T3 Code app. + +## Requirements + +- A current Xcode release with an iOS Simulator runtime. +- iOS 17 or later for physical-device builds. +- A T3 pairing URL for direct connections. T3 Connect builds additionally need + the cloud settings below. ## Open Open `T3Code.xcodeproj`, choose the `T3Code` scheme, and run an installed iOS -simulator. Xcode automatically includes Swift files added below `App`, `Core`, -`Features`, and `DesignSystem`. +Simulator. Xcode automatically includes files added below `App`, `Core`, +`Features`, `DesignSystem`, and `Resources`; `Info.plist` is the one resource +excluded from copying because it supplies the target's generated Info.plist. Pair with the same URL produced by a T3 server. The one-time pairing credential is exchanged for an access token and stored in the Keychain. Environment metadata and @@ -28,46 +37,92 @@ the active selection are stored separately in Application Support. ## Included - Local-network preflight, direct pairing links, QR scanning, token exchange, - Keychain credentials, and saved environment management. + Keychain credentials, saved environment management, and optional T3 Connect + account and relay discovery. - A merged Web V2 home across saved environments, with per-device reachability, collision-safe identities, last-known rows, live active-device updates, and low-frequency passive refresh. -- Server-side project creation from a known workspace path, plus thread search, - creation, rename, archive, restore, delete, settle, snooze, runtime mode, and - interaction mode. +- Remote filesystem browsing, source discovery, repository cloning, project + creation, plus thread search, creation, rename, archive, restore, delete, + settle, and snooze. - Provider/model selection, synchronized conversation history, rich Markdown, photo/camera/file image attachments, turn cancellation, approval decisions, and structured user-input requests. - Workspace files and previews, working-tree review, Git status and common actions, plus an interactive terminal session scoped to each thread. -- Native settings with persisted appearance and behavior preferences. +- Native settings with persisted appearance and behavior preferences, platform + deep links, shortcuts, and local notification routing. -The app speaks the existing HTTP and Effect RPC WebSocket contracts directly. No -JavaScript runtime or third-party package is embedded. +The app speaks the existing HTTP and Effect RPC WebSocket contracts directly. It +does not embed a JavaScript runtime. -## Current gaps +## Build configuration -- T3 Connect account sign-in, managed relay environment discovery, and push/live - activity registration are not implemented. Pairing is direct to an environment. -- Adding a project requires entering a path that exists on the server. Remote - filesystem browsing, repository cloning, and source-control account discovery are - not implemented yet. -- The active environment uses the reconnecting WebSocket stream with HTTP polling - as a fallback. Other environments refresh every 20 seconds, so their home rows - can lag briefly. An open passive-device thread refreshes every two seconds and - stops when its detail view closes. Last-known passive rows are retained in - memory, not across a cold app launch. -- Notification deep links are not implemented. Source-control status currently - reflects changed paths but the server response does not distinguish staged files - or individual change kinds. +The project expands these user-defined Xcode build settings into its generated +Info.plist: + +| Setting | Required | Purpose | +| --- | --- | --- | +| `T3CODE_CLERK_PUBLISHABLE_KEY` | T3 Connect only | Clerk publishable key. | +| `T3CODE_CLERK_JWT_TEMPLATE` | No | Relay JWT template; defaults to `t3-relay`. | +| `T3CODE_RELAY_URL` | T3 Connect only | Relay base URL using HTTPS. | +| `DEVELOPMENT_TEAM` | Device/archive | Apple Developer team used by automatic signing. | +| `PRODUCT_BUNDLE_IDENTIFIER` | No | Defaults to `com.t3tools.t3code.swiftui`. | +| `MARKETING_VERSION` | Release | User-facing version. | +| `CURRENT_PROJECT_VERSION` | Release | Monotonically increasing build number. | + +Unset T3 Connect values disable that connection method without affecting direct +pairing. Supply settings on the `xcodebuild` command line or through a local +`.xcconfig`; do not commit private release configuration. + +This app registers only the `t3code-swiftui` URL scheme so its routes do not +collide with another installed T3 Code client. ## Verify -Run the `T3Code` scheme's tests in Xcode, or use: +Run the `T3Code` scheme's tests in Xcode, or use the same entry point as CI. It +chooses an available iPhone from the newest installed Simulator runtime: ```sh -xcodebuild test \ - -project T3Code.xcodeproj \ - -scheme T3Code \ - -destination 'platform=iOS Simulator,name=iPhone 17 Pro' +./Scripts/ci-test.sh ``` + +Set `T3_SWIFT_SIMULATOR_ID` to pin a specific simulator. The path-filtered +`.github/workflows/swift-ios.yml` workflow runs this native unit-test target on +pull requests and pushes to `main` that change the Swift app. + +## Install on a physical device + +Enable Developer Mode on the device, connect and trust the Mac, then find its +identifier with `xcrun devicectl list devices`. Xcode must be signed into an Apple +Developer account for the requested team. + +```sh +T3_SWIFT_DEVICE_ID="DEVICE-IDENTIFIER" \ +T3_SWIFT_DEVELOPMENT_TEAM="TEAMID1234" \ +./Scripts/install-device.sh +``` + +The script builds, provisions, installs, and launches the app. It accepts the T3 +Connect build settings above as environment variables. Optional overrides are +`T3_SWIFT_BUNDLE_IDENTIFIER`, `T3_SWIFT_CONFIGURATION`, +`T3_SWIFT_DERIVED_DATA_PATH`, `T3_SWIFT_VERSION`, and +`T3_SWIFT_BUILD_NUMBER`. + +## Release checklist + +1. Set a unique `MARKETING_VERSION` and a higher `CURRENT_PROJECT_VERSION`. +2. Confirm the production bundle identifier, display name, app icon, signing team, + and T3 Connect HTTPS relay configuration. +3. Run `./Scripts/ci-test.sh` and confirm the Swift iOS GitHub workflow is green. +4. Smoke-test direct URL and QR pairing, T3 Connect, multi-environment navigation, + task creation, follow-up messages, attachments, approvals, input requests, + background/reconnect behavior, and deep links on an iPhone and iPad. +5. If remote push is shipping, add the APNs entitlement and matching provisioning + before archiving, then verify device-token registration end to end. Local + notifications do not require that entitlement. +6. Archive the `T3Code` scheme in Release, run Xcode's Validate App and privacy + report, and confirm `PrivacyInfo.xcprivacy` is bundled. Re-audit the manifest + whenever code adds a Required Reason API or data collection. +7. Confirm `ITSAppUsesNonExemptEncryption = NO` remains accurate, then distribute + an internal TestFlight build before App Store submission. diff --git a/apps/swift-ios/Resources/PrivacyInfo.xcprivacy b/apps/swift-ios/Resources/PrivacyInfo.xcprivacy new file mode 100644 index 0000000000..396aeea9d1 --- /dev/null +++ b/apps/swift-ios/Resources/PrivacyInfo.xcprivacy @@ -0,0 +1,21 @@ + + + + + NSPrivacyTracking + + NSPrivacyCollectedDataTypes + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA92.1 + + + + + diff --git a/apps/swift-ios/Scripts/ci-test.sh b/apps/swift-ios/Scripts/ci-test.sh new file mode 100755 index 0000000000..dcc69cb476 --- /dev/null +++ b/apps/swift-ios/Scripts/ci-test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +APP_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" +SIMULATOR_ID="${T3_SWIFT_SIMULATOR_ID:-}" +DERIVED_DATA_ROOT="${RUNNER_TEMP:-${APP_DIR}/.derivedData}" +DERIVED_DATA_PATH="${T3_SWIFT_DERIVED_DATA_PATH:-${DERIVED_DATA_ROOT}/swift-ios-ci}" + +die() { + printf '[swift-ios-ci] error: %s\n' "$*" >&2 + exit 1 +} + +require_cmd() { + command -v "$1" >/dev/null 2>&1 || die "missing required command: $1" +} + +require_cmd awk +require_cmd xcodebuild +require_cmd xcrun + +if [[ -z "${SIMULATOR_ID}" ]]; then + # simctl groups devices by runtime. Keeping the last available iPhone picks + # the newest installed iOS runtime without coupling CI to a device model. + SIMULATOR_ID="$( + xcrun simctl list devices available \ + | awk -F '[()]' '/^[[:space:]]+iPhone/ { candidate=$2 } END { print candidate }' + )" +fi + +[[ -n "${SIMULATOR_ID}" ]] || die "no available iPhone simulator was found" + +printf '[swift-ios-ci] Xcode: %s\n' "$(xcodebuild -version | tr '\n' ' ')" +printf '[swift-ios-ci] simulator: %s\n' "${SIMULATOR_ID}" + +xcodebuild test \ + -project "${APP_DIR}/T3Code.xcodeproj" \ + -scheme T3Code \ + -configuration Debug \ + -destination "platform=iOS Simulator,id=${SIMULATOR_ID}" \ + -derivedDataPath "${DERIVED_DATA_PATH}" \ + -maximum-concurrent-test-simulator-destinations 1 \ + -only-testing:T3CodeTests \ + CODE_SIGNING_ALLOWED=NO diff --git a/apps/swift-ios/Scripts/install-device.sh b/apps/swift-ios/Scripts/install-device.sh new file mode 100755 index 0000000000..d2f8b2c12f --- /dev/null +++ b/apps/swift-ios/Scripts/install-device.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +APP_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" +DEVICE_ID="${T3_SWIFT_DEVICE_ID:-${1:-}}" +DEVELOPMENT_TEAM="${T3_SWIFT_DEVELOPMENT_TEAM:-${2:-}}" +CONFIGURATION="${T3_SWIFT_CONFIGURATION:-Debug}" +BUNDLE_IDENTIFIER="${T3_SWIFT_BUNDLE_IDENTIFIER:-com.t3tools.t3code.swiftui}" +DERIVED_DATA_PATH="${T3_SWIFT_DERIVED_DATA_PATH:-${APP_DIR}/.derivedData/device}" + +die() { + printf '[swift-ios-device] error: %s\n' "$*" >&2 + exit 1 +} + +require_cmd() { + command -v "$1" >/dev/null 2>&1 || die "missing required command: $1" +} + +require_cmd xcodebuild +require_cmd xcrun + +[[ -n "${DEVICE_ID}" ]] || die \ + "set T3_SWIFT_DEVICE_ID to an identifier from 'xcrun devicectl list devices'" +[[ -n "${DEVELOPMENT_TEAM}" ]] || die \ + "set T3_SWIFT_DEVELOPMENT_TEAM to your Apple Developer team ID" +[[ "${CONFIGURATION}" == "Debug" || "${CONFIGURATION}" == "Release" ]] || die \ + "T3_SWIFT_CONFIGURATION must be Debug or Release" + +build_settings=( + "DEVELOPMENT_TEAM=${DEVELOPMENT_TEAM}" + "PRODUCT_BUNDLE_IDENTIFIER=${BUNDLE_IDENTIFIER}" +) + +for key in \ + T3CODE_CLERK_PUBLISHABLE_KEY \ + T3CODE_CLERK_JWT_TEMPLATE \ + T3CODE_RELAY_URL; do + value="${!key:-}" + if [[ -n "${value}" ]]; then + build_settings+=("${key}=${value}") + fi +done + +if [[ -n "${T3_SWIFT_VERSION:-}" ]]; then + build_settings+=("MARKETING_VERSION=${T3_SWIFT_VERSION}") +fi +if [[ -n "${T3_SWIFT_BUILD_NUMBER:-}" ]]; then + build_settings+=("CURRENT_PROJECT_VERSION=${T3_SWIFT_BUILD_NUMBER}") +fi + +printf '[swift-ios-device] building %s for %s\n' "${BUNDLE_IDENTIFIER}" "${DEVICE_ID}" +xcodebuild build \ + -project "${APP_DIR}/T3Code.xcodeproj" \ + -scheme T3Code \ + -configuration "${CONFIGURATION}" \ + -destination "platform=iOS,id=${DEVICE_ID}" \ + -derivedDataPath "${DERIVED_DATA_PATH}" \ + -allowProvisioningUpdates \ + "${build_settings[@]}" + +APP_PATH="${DERIVED_DATA_PATH}/Build/Products/${CONFIGURATION}-iphoneos/T3Code.app" +[[ -d "${APP_PATH}" ]] || die "built app was not found at ${APP_PATH}" + +printf '[swift-ios-device] installing %s\n' "${APP_PATH}" +xcrun devicectl device install app --device "${DEVICE_ID}" "${APP_PATH}" + +printf '[swift-ios-device] launching %s\n' "${BUNDLE_IDENTIFIER}" +xcrun devicectl device process launch --device "${DEVICE_ID}" "${BUNDLE_IDENTIFIER}"