Repository Public
1# Development guide23How to build, test and run SPB Git for iOS and iPadOS, and the conventions the code follows.4Architecture and "how to add a feature" are in [`IOS_ARCHITECTURE.md`](IOS_ARCHITECTURE.md).56## Requirements78- Xcode 27.2 (iOS SDK 27.2), a simulator runtime iOS 26.5 or later, `xcodegen` (`brew install xcodegen`).9- No package, no pod, no third-party dependency: nothing to resolve.10- Deployment target iOS and iPadOS 26.0. Swift 6 language mode, strict concurrency `complete`.1112## Project1314The Xcode project is generated from `project.yml`:1516```bash17xcodegen generate18```1920Both `project.yml` and the generated `SPBGit.xcodeproj` are committed. Sources are picked up by folder: adding21a Swift file under `SPBGit/`, `SPBGitTests/` or `SPBGitUITests/` needs no project edit, only a regeneration22(`scripts/build.sh` does it every time). Files named `*.md` and `.gitkeep` under `SPBGit/` are not bundled.2324| Target | Kind | Bundle identifier |25|---|---|---|26| `SPBGit` | application, iPhone and iPad | `ai.spboucher.git` |27| `SPBGitWidgets` | WidgetKit extension embedded in the app | `ai.spboucher.git.widgets` |28| `SPBGitTests` | unit tests hosted by the app (Swift Testing) | `ai.spboucher.git.tests` |29| `SPBGitUITests` | UI tests (XCTest) | `ai.spboucher.git.uitests` |3031Version `1.0.0`, build `1` (`MARKETING_VERSION`, `CURRENT_PROJECT_VERSION` in `project.yml`). Team `3YM54G49SN`.3233## Build and test3435This machine once froze under parallel Xcode builds. Run **one `xcodebuild` at a time**. `scripts/build.sh`36enforces it: it waits while any other `xcodebuild` process is running, writes the full output to37`build/logs/` and prints only errors and test totals.3839```bash40scripts/build.sh build # app + test bundles, simulator41scripts/build.sh test # unit tests (SPBGitTests)42scripts/build.sh test SPBGitTests/DeepLinkTests # one suite (any -only-testing identifier)43scripts/build.sh uitest # UI test: launches the real app, checks the five tabs44scripts/build.sh test SPBGitUITests/InsightsUITests # UI tests against the live forge: search typing, insights, explorer45scripts/build.sh live # live visitor-pass round trip against production (see below)46scripts/build.sh test SPBGitUITests/PlatformUITests # live: spbgit:// links, an offline download read without network, keyboard shortcuts47scripts/build.sh test SPBGitUITests/ReadPathUITests # live: Home → repository → file → history → commit → diff, and back to Home48scripts/build.sh test SPBGitUITests/AccessibilityAuditUITests # live: performAccessibilityAudit on 18 screens, light and dark (about 15 min)49python3 scripts/l10n-audit.py # after a build: every string of the app and the widgets is in the catalog, in English and French;50 # every App Shortcut phrase has its French form (AppShortcuts.xcstrings)51sp-header check . # source headers52```5354Derived data goes to `build/dd` (ignored by git). The destination is the simulator named `SPBGit iPhone`;55set `SPBGIT_SIMULATOR="SPBGit iPad"` to use the iPad.5657### Simulators5859Two dedicated devices, so that work on this app never disturbs another project's simulator:6061```bash62xcrun simctl create "SPBGit iPhone" com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro com.apple.CoreSimulator.SimRuntime.iOS-26-563xcrun simctl create "SPBGit iPad" com.apple.CoreSimulator.SimDeviceType.iPad-Pro-13-inch-M5-12GB com.apple.CoreSimulator.SimRuntime.iOS-26-564```6566Boot only the one you need and shut it down afterwards (`xcrun simctl shutdown "SPBGit iPhone"`).6768### Running the app from the command line6970```bash71APP=build/dd/Build/Products/Debug-iphonesimulator/SPBGit.app72xcrun simctl boot "SPBGit iPhone"73xcrun simctl install "SPBGit iPhone" "$APP"74xcrun simctl launch "SPBGit iPhone" ai.spboucher.git -SPBScreen repositories -SPBAppearance dark -SPBLocale fr75xcrun simctl io "SPBGit iPhone" screenshot build/screenshots/dev/repositories-dark-fr.png76```7778`scripts/screenshots.sh` does this for the standard set (Home, Repositories, one repository; light and dark;79English and French) into `build/screenshots/dev/`, which git ignores: development captures are not committed. The80curated set shown by the README is `docs/screenshots/` (16 images at most); the store set is81`docs/appstore/screenshots/`, produced by `scripts/appstore-screenshots.sh` (see below).8283### Store screenshots8485```bash86scripts/build.sh build87scripts/appstore-screenshots.sh # or: iphone | ipad88```8990Creates the simulators `SPBGit store iPhone` (iPhone 17 Pro Max, 1320 x 2868) and `SPBGit store iPad` (iPad Pro9113-inch, 2064 x 2752) when they do not exist, overrides the status bar (9:41, full battery, full signal), opens92eight screens by launch arguments in English and French, checks the pixel size of every file with `sips`, and93writes `docs/appstore/screenshots/{iphone-6.9,ipad-13}/{en,fr}/NN-name.png`. Code and diff are dark, the rest94light. The pictures are the real application on the data of the forge at that moment: run it once, look at95every file, run it again if a load was slow (the delay of each screen is in the table at the top of the script).9697## Launch arguments (Debug builds only)9899Parsed by `LaunchOptions` (`SPBGit/App/LaunchOptions.swift`) inside `#if DEBUG`: they do not exist in a100Release binary.101102| Argument | Values | Effect |103|---|---|---|104| `-SPBScreen` | `home`, `repositories`, `repository:<name>`, `activity`, `insights`, `profile`, `search` | opens on that tab, or on a repository inside the Repositories tab |105| `-SPBScreen` | `tree:<repository>:<ref>:<path>` (empty ref: default branch; empty path: root) | opens a directory in the file explorer |106| `-SPBScreen` | `blob:<repository>:<ref>:<path>` with an optional `#L<line>` suffix | opens a file in its viewer, at that line for code |107| `-SPBScreen` (history) | `commits:<repo>[:<ref>]`, `history:<repo>:<path>`, `commit:<repo>:<sha>`, `diff:<repo>:<sha>[:<path>]`, `graph:<repo>`, `branches:<repo>`, `tags:<repo>`, `releases:<repo>`, `compare:<repo>:<base>:<head>` | opens that history screen under its repository (`LaunchOptions+History.swift`) |108| `-SPBActivity` | `following`, `today`, `week`, `month`, or an event type (`tag_created`…) | filter the Activity tab starts with |109| `-diff.sideBySide`, `-diff.wrap` | `YES`, `NO` | diff viewer preferences for this launch (argument domain of `UserDefaults`) |110| `-SPBAppearance` | `light`, `dark` | forces the appearance |111| `-SPBLocale` | `en`, `fr` | forces the language (and the `en_CA` / `fr_CA` region) for this launch |112| `-SPBVisitorPass` | `off` | does not request a visitor pass at launch (UI tests, repeated launches) |113| `-SPBScrollTo` | `readme` | a repository opens scrolled to its README (store screenshots) |114| `-SPBScreen` (features) | `insights:<activity\|code\|repositories\|research\|apple\|compare>`, `metric:<chart id or figure.<id>>`, `collection:<id>`, `repository-insights:<name>`, `search:<text>`, `compare:<a,b,…>` | opens a group of Insights, a metric detail (`MetricChart` / `MetricFigure` raw values), a collection, the insights of a repository, a search that runs at once, a comparison |115| `-SPBSearch` | `scope=<all\|repos\|files\|code\|readmes\|commits\|branches\|tags>,repository=<name>,language=<name>,regex=1,word=1,case=1,exact=1` | scope and filters of `-SPBScreen search:<text>` |116| `-SPBRepositories` | `layout=<list\|grid>,language=<name>,topic=<name>,collection=<id>,sort=<activity\|name\|created\|size\|commits>,favourites=1,text=<words>` | initial state of the explorer |117| `-SPBHome` | `range=<month\|quarter\|year\|all>,year=<yyyy>` | period of the activity chart and year of the contribution calendar on Home |118| `-SPBScreen` (owner) | `settings`, `administration`, `admin-overview`, `audit[:<repo>]`, `tokens`, `new-repository`, `edit-repository:<repo>`, `changes:<repo>:<branch>`, `edit:<repo>:<branch>:<path>` | opens that owner screen (`LaunchOptions+Owner.swift`) |119| `-SPBServer` | `http://127.0.0.1:7431` | targets a local development server (loopback addresses only), with its own cache directory, Keychain service and drafts folder |120| `-SPBOwnerToken` | a token of the local server | signs in at launch (verified with `whoami`); accepted only together with `-SPBServer` |121| `-SPBBiometry` | `allow`, `deny` | replaces Face ID by a stub that accepts or refuses (the simulator has no enrolled biometry) |122| `-SPBOwnerReset` | | removes the stored development token before starting |123124| `-SPBOffline` | (flag) | no network for this launch: the client answers `offline` to everything it cannot serve from an offline copy or the cache, `Reachability` says offline |125| `-SPBScreen` (platform) | `offline`, `notifications`, `widgets[:<1-4>]`, `offline-download:<repo>` | the Offline screen, the notification settings, the widget gallery (one page of it), a repository whose offline download starts at once |126| `-SPBBackgroundCheck` | `run`, `rewind` | runs the handler of the background refresh once at launch (`rewind`: as if the last check were a day old) |127| `-SPBFollow`, `-SPBNotifications` | `<repo>`, `provisional` | follows a repository; turns notifications on with a provisional authorisation (no prompt) |128129A launch with `-SPBScreen` does not restore the navigation a previous launch left (`SceneStorage`).130131When the process hosts the unit tests (`XCTestConfigurationFilePath` in the environment) the app builds no132interface and makes no request.133134## Tests135136Unit tests use Swift Testing (`import Testing`, `@Suite`, `@Test`, `#expect`). They never touch the network:137138- `SPBGitTests/TestSupport/StubServer.swift`: an in-process forge. Each `StubServer` owns a `URLSession`139 routed by `StubURLProtocol` (one private host per instance, so suites run in parallel) and records the140 requests it received. `server.makeClient()` returns an `APIClient` wired to it with a private disk cache.141- `SPBGitTests/Fixtures/*.json`: payloads.142 - Files without prefix are **real production answers** (server 3.2.0), fetched with `curl` and trimmed:143 `repos`, `repo`, `languages`, `commits`, `tree`, `releases`, `search`, `stats`, `healthz`,144 `error_not_found`, `pass_challenge`.145 - Files prefixed `v33_` are **written from `docs/API_CONTRACT.md` section 2** (server 3.3.0, not deployed146 when they were written). When 3.3.0 ships, replace them with real answers and fix what differs.147 - `metrics`, `repo_metrics`, `metrics_compare`, `collections`, `search_code_shield`, `search_all_shield`, `search_tags`,148 `suggestions` are **real 3.3.0 answers** (2026-12-02), trimmed; the metric, chart-preparation and search tests use them.149- To refresh a real fixture: `curl -s -A "SPBGit-iOS/1.0.0 (1; iOS 26.5)" https://git.spboucher.ai/api/v1/stats`,150 trim, save. Do not loop over costly routes (`tree`, `commits`, `search`, `raw`): the shield budget is tiny.151152### Live visitor-pass test153154`VisitorPassLiveTests` talks to `https://git.spboucher.ai` for real: challenge, proof of work, redeem, then a155`tree` and a `commits` request with the pass. It is skipped unless the test process has `SPBGIT_LIVE=1`:156157```bash158scripts/build.sh live # sets TEST_RUNNER_SPBGIT_LIVE=1, prints the lines starting with "LIVE:"159```160161The server issues **six passes per hour and per address** while in attack mode: run it once, not in a loop.162163## Owner mode: the local development server164165Authenticated and write development never touches `https://git.spboucher.ai`. It runs against a throw-away166spbgit 3.3.0 on `127.0.0.1:7431`, started from a checkout of the server (`SPBGIT_SERVER_DIR`, by default167`../../_spbgit-server-work`, only read) with its data under `build/devserver/` (ignored by git):168169```bash170scripts/devserver.sh seed # bare clones of two small public repositories + one empty repository171scripts/devserver.sh start # stop | status | reset172scripts/devserver.sh token "my iPhone" repo:write,tokens 30 # label, scopes (none: every scope), days173scripts/devserver.sh expired-token174scripts/devserver.sh push <repo> <branch> <path> <text> # a push from the shell, to provoke head_moved175176xcrun simctl launch "SPBGit iPhone" ai.spboucher.git -SPBServer http://127.0.0.1:7431 \177 -SPBOwnerToken "$TOKEN" -SPBBiometry allow -SPBScreen administration178179scripts/owner-integration.sh # SPBGitTests/OwnerIntegrationTests: every write and every refusal180scripts/owner-integration.sh ui # SPBGitUITests/OwnerUITests: the owner flows in the real app181```182183Both suites are skipped without the environment the script sets, and refuse any host that is not a loopback184address. A Debug build reads its Info.plist from `Resources/Info-Debug.plist`, which is `Info.plist` plus185`NSAllowsLocalNetworking` (plain HTTP to the local server); `OwnerPlistTests` checks that this is the only186difference and that the Release plist has no App Transport Security key. Keep the two files in step.187188## Localization189190- Development language English, plus French (Québec). One String Catalog:191 `SPBGit/Resources/Localizable.xcstrings`. Keys are the English strings.192- In views, `Text("…")`, `Label("…", systemImage:)`, `Button("…")` with a **literal** are localized. A193 `String` variable is not: for a conditional title write `let title: LocalizedStringKey = flag ? "A" : "B"`.194- Outside views use `String(localized: "…")`; for values passed around use `LocalizedStringResource`.195- Text that is data (repository names, hashes, paths) uses `Text(verbatim:)`.196- Counts use plural variations in the catalog (`%lld commits`).197- `python3 scripts/l10n-audit.py` (after a build) fails when a string used by the code is missing from the198 catalog or has no French translation.199- Two counts in one sentence are two strings, each with its plural forms, joined in code200 (`SPBFormat.lineChanges`): "1 addition, 2 deletions", never "1 additions".201202### Glossary (French)203204One term per notion, in every feature. Checked on the whole catalog on 2026-12-03.205206| English | French | Notes |207|---|---|---|208| repository | dépôt | |209| branch | branche | |210| tag | étiquette | |211| release | version (publiée) | "Versions" as a title; "fichier de version" for a release file |212| commit, to commit | commit, commiter | "commité" for the past participle |213| push (noun), pushed | poussée, poussé | "notifications push" is Apple's own term and stays |214| hash | empreinte | |215| ref | référence | |216| favourite | favori | |217| pinned | épinglé | |218| followed | suivi | "ne plus suivre" for unfollow |219| offline | hors ligne | |220| topic | sujet | |221| collection | collection | |222| insights | analyses | tab and section title |223| changes (diff) | modifications | "Voir les modifications" |224| staged | en attente | "mettre en attente" |225| draft | brouillon | |226| access token, scope | jeton d'accès, portée | |227| shield | bouclier (anti-moissonnage) | |228| owner mode | mode propriétaire | |229| permalink | lien permanent | |230| clone | cloner, commande de clonage | |231| download | télécharger, téléchargement | |232| settings | réglages | as in iOS |233234235## Conventions236237- **Files**: one type or one cohesive group per file, at most about 300 lines including the header.238- **Source header**: every Swift file starts with the official SP Boucher header. A hook adds it on write;239 `sp-header fix .` adds missing ones, `sp-header check .` validates. Do not write it by hand. Comments must240 not contain phrases that mark a file as produced by a tool (the engine then skips the file).241- **Design system only**: colours from `SPBColor`, fonts from `SPBTypography`, spacing from `SPBSpacing`,242 animations through `spbAnimation` / `SPBMotion.animation(_:reduceMotion:)`. No literal colour, no fixed243 font size in a feature.244- **Loading**: a screen exposes `LoadState<Value>` and renders it with `LoadableView`.245- **Navigation**: `NavigationLink(value: Route.…)` or `router.open(_:)`; never a destination closure.246- **Networking**: features talk to services (`RepositoryService`…), never to `APIClient` or `URLSession`.247 Load from `.task` (cancelled when the view disappears); never one request per row.248- **Previews**: every design-system component has a `#Preview`. Samples live in249 `SPBGit/PreviewSupport/PreviewData.swift`, compiled in Debug only; production code has no sample data.250- **Colours**: edit the table in `scripts/generate-colors.py`, run it, commit the colour sets.251- **Commits**: Conventional Commits in English, one coherent step each, `sp-git commit -m "…" <files>` then252 `sp-git push`.253- **Never**: a secret in the repository, an ATS exception, a third-party SDK, a WebView.254255## Offline, widgets and platform tests256257- `SPBGitTests/TestSupport/OfflineForge.swift` serves a small repository through a `StubServer`, with real git258 object ids; `offline_blob_gitignore`, `offline_tree_root`, `offline_tree_scripts` and `platform_branches` are real259 3.3.0 answers.260- Widgets cannot be added to the simulator home screen by a script. Their views are in `Shared/` and the Debug261 gallery (`-SPBScreen widgets`, pages `widgets:1` to `widgets:4`) draws every widget in every family with the262 figures the forge gives at that moment, plus the placeholder, unconfigured and unavailable states.263- `xcrun simctl openurl` with a `spbgit://` link shows the system confirmation alert, which a script cannot accept:264 `PlatformUITests` uses `XCUIApplication.open(_:)` instead.265- The keyboard shortcut UI test is opt-in (`TEST_RUNNER_SPBGIT_KEYBOARD=1`, iPad simulator): synthesized ⌘ keys266 reach the app in some runs and not in others with the same build. `RouterPlatformTests` covers the logic.267- Universal Links, Handoff, APNs and the real background refresh need a signed build on a device.268