Skip to content

Latest commit

 

History

History
221 lines (167 loc) · 11.9 KB

development.md

File metadata and controls

221 lines (167 loc) · 11.9 KB

Development

The local loop: set up, build, run, regenerate. Shipping a build is release.md; verifying a change is testing.md.

Requirements

  • macOS 26 or later (Liquid Glass).
  • Xcode 27: it provides the SwiftUI macro plugin and the SDK.
  • XcodeGen, and for linting: brew install swiftlint.
  • Node, for the generators and the local stub servers some test suites start. It is the only scripting runtime here; building the app still needs none of it.

First-time setup

Create the Tinycast Self-Signed code-signing identity once. Builds sign with it, which is what keeps macOS from forgetting the Accessibility grant on every rebuild. Follow signing.md §1, a few openssl/security commands.

Working on iCloud Sync needs the team's Apple Development signing instead; see signing.md. Without it everything else builds and runs as before.

That is the whole required setup. Editor configuration is personal and the repo does not prescribe it; the section below is a note for anyone who wants it, not a step.

Build & run

open Tinycast.xcodeproj    # then ⌘R

Or from the command line:

xcodebuild -project Tinycast.xcodeproj -scheme Tinycast -configuration Debug build

xcodebuild uses whatever xcode-select points at; if that's the Command Line Tools rather than Xcode, prefix with DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer (the SwiftUI @State/@FocusState macros need Xcode's macOS platform).

Tinycast.xcodeproj is committed and generated from project.yml via XcodeGen. After changing project settings in project.yml, run xcodegen generate and commit the result. There is no Package.swift, and Bundle.module must never be used.

The app target builds and embeds ClipboardTextHelper under Contents/Helpers, signing it on copy. Build the app scheme to include it; copying only the main executable omits OCR support. The helper's executable name stays fixed even when release builds override the app's product name for a channel.

Dictation similarly embeds its Swift/Core ML helper, named Tinycast Dev Dictation in Debug and Tinycast Dictation in Release, in an accessory .app bundle without a bundled icon. Model weights download on demand; none are app resources.

The dev channel

Debug builds are a separate channel: Tinycast Dev.app, bundle id com.abueammar.tinycast.dev. Every persisted thing is keyed by bundle id: ~/Library/Preferences/<id>.plist (settings and hotkey bindings), ~/Library/Application Support/<id>/ (the onboarding marker, Notes, snippets, quicklinks, clipboard history, calculator history, launch ranking and frequent emoji; Notes and snippets unless a folder is chosen), ~/Library/Caches/<id>/ (exchange rates, the update check, staged downloads), the opt-in ~/.config/tinycast-dev/settings.json (tinycast on stable), the tinycast-dev:// link scheme (tinycast:// on stable), the SMAppService login item, and the Accessibility / Input Monitoring (TCC) grants, so a local build can neither read nor clobber an installed app's state, and both run side by side.

What earns a place in Caches is refetchable, and nothing else. Anything the user would notice the loss of goes in Application Support: ~/Library/Caches is excluded from Time Machine and the system reclaims it under disk pressure without saying so.

Consequences worth knowing:

  • The dev build asks for Accessibility on its own the first time, and starts with no hotkeys bound and onboarding unseen. Grant and bind once; it persists across rebuilds, because the fixed build path and the Tinycast Self-Signed identity keep the TCC grant alive.
  • Don't bind the same global hotkey in both; whichever registered first wins.
  • The Hyper Key's Caps Lock remap lives on the keyboards, which are shared, not per-bundle: enable Hyper in one build at a time so their keyboard owners do not compete. An identical mapping already installed by another build is left unowned.

Debugging Settings

Settings runs as a second instance of the app, started with --role=settings and linked to the main app over its stdin and stdout, so it cannot be launched on its own. Open Settings, then attach Xcode's debugger to that process (Debug › Attach to Process, the Tinycast Dev entry whose arguments name the role). See architecture.md.

Editor

Xcode works out of the box and needs nothing here. Everything below is optional, and which editor you use is your business; the repo prescribes none of it.

VS Code gets code intelligence from SourceKit-LSP, which needs a buildServer.json because there is no Package.swift. Build once, then hand the log to the sync script; that writes both buildServer.json and the flag database:

brew install xcode-build-server
xcodebuild -project Tinycast.xcodeproj -scheme Tinycast -configuration Debug \
    -derivedDataPath build/DerivedData build 2>&1 | tee /tmp/tinycast-build.log
./Scripts/sync-lsp.sh /tmp/tinycast-build.log

Both files are git-ignored because they embed absolute paths, and sourcekit-lsp looks for buildServer.json at the workspace root by name, so it cannot live in a subfolder. After this the Build Tinycast.app (debug) task (⌘⇧B) and F5 re-run the script on every build, so new and renamed files keep resolving.

Do not run xcode-build-server config. It writes kind: xcode, and in that mode the server ignores .compile entirely: it serves flags from a cache it scrapes out of .xcactivitylog instead. That cache is only refreshed when LogStoreManifest.plist advances, and when the manifest stops updating (it does) the editor silently pins itself to the source list from some older build: every reference to a file added since reads cannot find type X in scope, in every file, until you restart the server. It also mixes Release entries in with Debug and lets them win. Scripts/sync-lsp.sh keeps the mode manual, where .compile is the single source of truth.

Tests in the editor

TinycastTests is an ordinary target of the project, so .compile covers the suites once a build has compiled them: the Build Tinycast.app (debug) task builds with build-for-testing for that reason. Re-run it after adding a suite, then Swift: Restart LSP Server from the Command Palette; an already-running server does not re-read .compile.

Xcode's test navigator lists and runs the suites with no setup. VS Code's Swift extension discovers tests only in SwiftPM packages, so there run a suite with xcodebuild test … -only-testing:TinycastTests/<Suite> (testing.md).

Linting

./Scripts/lint.sh          # lint the whole project
./Scripts/lint.sh --fix    # auto-correct the mechanical subset first

SwiftLint is the only code-quality tool here. .swiftlint.yml at the repo root excludes the generated files and the two off-limits files in DesignSystem/Scrolling/. The comment policy in standards.md is deliberately not among its rules.

lint.sh also runs check-localizations.js, which fails on a string missing from any language, a missing plural form, a stale entry, or a translation whose format specifiers differ from the source.

Localization

./Scripts/sync-strings.sh   # build, merge new UI strings into Localizable.xcstrings, then check it

xcodebuild extracts strings but never writes them back to the catalog (only a build in Xcode's IDE does), so run this after changing UI text, then translate what it added (Xcode's catalog editor, or the JSON directly). A string whose source changed leaves its old entry stale; delete it. The rules for writing localizable code are in standards.md.

To see a language without changing the setting, launch the Debug build with -AppleLanguages '(de)'; add -NSDoubleLocalizedStrings YES to find labels that truncate.

Formatting

./Scripts/format.sh            # format Tinycast/ and Tests/ in place
./Scripts/format.sh --check    # report what would change, write nothing (exit 1 if any)

swift-format from the Xcode toolchain: the same binary sourcekit-lsp formats with, so ⌘S in VS Code and this script cannot disagree. .swift-format at the repo root tunes it to this tree; without it the stock config defaults to 2-space indent and rewrites all 200 files.

Every *.generated.swift file is excluded: formatting one is hand-editing it, and the next node Scripts/gen-emoji.js would revert it. swift-format also refuses any file that does not parse, so a failure from either command is a syntax error rather than a tooling problem, and it is why ⌘S looks like it does nothing while a file is mid-edit with unbalanced braces. The two protected scrolling primitives, EdgeDissolve.swift and ThinScrollbar.swift, are also excluded.

Think twice before leaning on this. A formatter was rejected here on measured evidence, and that stands: running it over the tree touched 68 files, and 67 of those changed more than whitespace.

The config sticks to rules that catch defects and stays quiet about style, because there is no formatter, on measured evidence. Formatting is Xcode's re-indent (⌃I), as it always has been. Two consequences worth knowing:

  • empty_count is disabled, and isEmpty-style rewrites are unsafe here generally: LauncherRankingRecord and PaletteRowIndex have a count that is a hit count, not a collection count. A rule that rewrites count > 0 to !isEmpty on them does not compile.
  • force_try is an error; force_cast only warns, because the AX and AppKit bridges have four legitimate ones.

Errors block, warnings do not. No CI runs this script, so run it locally before you open a PR.

Generated data

Three Swift files are emitted by scripts and must never be hand-edited. Each downloads its source, so run them online, then commit the result:

node Scripts/gen-emoji.js            # -> Tinycast/Features/Emoji/Model/EmojiData.generated.swift
                                     #    + Tinycast/Resources/EmojiKeywords/<language>.txt
node Scripts/gen-currencies.js       # -> Tinycast/Features/Calculator/Model/CurrencyData.generated.swift
node Scripts/gen-countries.js        # -> Tinycast/Features/Calculator/Model/CountryZoneData.generated.swift

gen-emoji.js also writes one CLDR keyword pack per language in its KEYWORD_LOCALES; adding a language is one line there. Pass a directory to keep the downloads between runs: node Scripts/gen-emoji.js /tmp/emoji-sources.

gen-countries.js joins IANA's zone.tab with CLDR's en territory names on the ISO 3166 code. Re-run it when IANA adds or moves a country's zone; see calculator.md.

gen-currencies.js joins three sources on the ISO code: the fiat rate feed's own quote list (the same feed CurrencyRateStore fetches rates from, so the table and the rate source cannot drift apart), Unicode CLDR's en currency data, which supplies display names, signs and the singular/plural noun, and CLDR's supplemental currency data, which says which codes are still spent anywhere. That last one is not optional: the feed carries no retirement metadata and quotes codes their countries abandoned years ago. Both CLDR files are read from the pinned cldr-json checkout rather than the host's Intl, whose output shifts with the local ICU version and would make the file unreproducible.

Only unambiguous data is emitted. Anything two currencies claim (dollars, pounds, krona) is left out and decided by hand in CalcCurrency.contested. The crypto tickers aren't generated at all: they have no external source of truth, so CalcCurrency.crypto is hand-written, and that same list is the set of symbols the fetch asks for. Re-run the script when a currency is added or retired; nothing breaks in the meantime, since an unquoted code just reports "no exchange rate".