CFA Reference: Xcode Templates
Formal CFA AI Toolkit for iOS Documentation · Reference 21 of 26
The toolkit installs three native templates into Xcode's File → New → Project chooser. Each creates a new, runnable CFA app; none modifies an existing project.
Definitions
- CFA App: The general-purpose foundation. A tab bar, a launch refresh, a real public-network request, a JSON file cache, retry and failure states, persistent colour themes and focused tests. It is maintained directly in its .xctemplate folder.
- Habit Tracker: Habit tracking, daily progress, streaks and SwiftData persistence. Generated from the Habit Tracker Starter App.
- Day Streak: Daily multiplication practice with reusable streak behaviour. Generated from the Todays Twenty Starter App; it is not a blank streak-only foundation.
- CFA-TEMPLATE.json: The template's metadata file, recording product cooperative-feature-architecture and version 1.
Rules
- Install with Install Xcode Template.command from the toolkit root, then quit and reopen Xcode.
- Choose File → New → Project → iOS → CFA App, Habit Tracker or Day Streak, then enter your product name and organisation identifier.
- Templates live in Project Templates/iOS/Application/ after installation.
- Do not hand-edit generated template sources. Edit the Starter App and run python3 scripts/sync-habit-template.py or python3 scripts/sync-day-streak-template.py; add --check to detect stale output.
- Running the installer again updates CFA-installed templates, keeps backup copies, and refuses to replace a same-named template from another source.
Decision rules
- When you want to learn CFA structure, choose CFA App.
- When your product tracks habits, choose Habit Tracker.
- When you want the multiplication-practice experience, choose Day Streak.
- When you need charts and a StoreKit example, open the Habit Tracker Pro Starter App; it is not an installer template.
Example
The CFA App template's GitReposFeature is a concrete @MainActor @Observable Feature. It keeps repos, isRefreshing and refreshError as separate values, depends on a GitReposProvider and a Repo cache through its initialiser, and stores its startup task with @ObservationIgnored. Its AppModel starts launch work like this:
Repository excerpt from the CFA App template's AppModel.swift
func applicationDidFinishLaunching() {
guard !hasFinishedLaunching else { return }
hasFinishedLaunching = true
gitReposFeature.startLoading()
}Compare it with the compiled AppModel in Reference 4.
Common mistakes
- Expecting Day Streak to be an empty app.
- Editing the generated Habit Tracker template instead of its Starter App.
- Forgetting to reopen Xcode after installing.
