╔═══════════════╗ ║ ❓ FAQ ║ ╠═══════════════╣ ║ Setup ║ ║ Architecture ║ ║ API ║ ║ Testing ║ ║ Contributing ║ ╚═══════════════╝

Developer FAQ

Common questions from Archon developers.

Q: How do I…? ───────────── A: Read the docs, check the code!
Developer Docs Archon iOS · Swift · SwiftUI API v1

Developer FAQ

Common questions from Archon developers.

FAQ Tabs

Setup

How do I get the Supabase credentials?

Create a free project at supabase.com. Go to Settings → API to find your project ref and anon key. The project ref is the first part of your Supabase URL.

Why do I need XcodeGen?

XcodeGen generates the .xcodeproj from project.yml. This keeps the project file out of version control (it changes constantly and causes merge conflicts) and makes it easy to add targets, dependencies, and build settings declaratively.

The build fails with "Missing Local.xcconfig" — what now?

Copy the template: cp Config/Local.xcconfig.template Config/Local.xcconfig. Then fill in your Supabase project ref and anon key. See the Setup guide for details.

Can I use Xcode instead of the command line?

Yes. After running xcodegen generate, open Archon.xcodeproj in Xcode and build/run normally. You only need the command line for the initial project generation and for CI/CD.

Do I need a physical device to develop?

No. The iOS Simulator works for most development. You only need a physical device for testing Keychain persistence, push notifications, and device-specific behaviors.

Architecture

Why MVVM instead of MVC or TCA?

MVVM with SwiftUI is Apple's recommended pattern. It keeps views declarative, ViewModels testable, and avoids the complexity of third-party frameworks. For Archon's scope, MVVM provides the right balance of structure and simplicity.

Why use APIClientProtocol instead of a concrete class?

Protocol-oriented design enables mock injection for unit tests and SwiftUI previews. ViewModels don't know or care whether they're talking to a real server or a mock — they just use the protocol. This makes every ViewModel fully testable without network calls.

How does the app handle offline states?

Currently, Archon requires a network connection for core features (AI chat, project sync). Failed network requests show error states with retry options. A future version may add offline caching for project files using local persistence.

Why is everything @MainActor?

Swift 6 strict concurrency requires explicit actor isolation. ViewModels update @Published properties that drive UI, so they must run on the main actor. This prevents data races and ensures UI updates happen on the main thread.

How do I add a new tab to the main interface?

Add a new TabItem in MainTabView.swift, create the ViewModel and View following conventions, and wire the API client. See Adding Features for the full walkthrough.

API

How do I add a new API endpoint?

Add a method to APIClient and MockAPIClient that calls request() with the appropriate method, path, and body. If it's a new resource, add the Codable model to Models/ first.

What happens when the API returns an error?

The APIClient maps HTTP status codes to APIError cases. ViewModels catch these and set @Published errorMessage properties, which views display as alert banners or inline errors.

How does token refresh work?

When a request returns 401, the client attempts a silent token refresh using the stored refresh token. If refresh succeeds, the original request is retried. If refresh fails, the user is redirected to the sign-in screen.

Why snake_case in the API but camelCase in Swift?

Supabase (PostgreSQL) uses snake_case for column names. Swift conventions use camelCase. The shared JSONDecoder with .convertFromSnakeCase handles the mapping automatically — you never need to use CodingKeys for standard properties.

How do I test streaming (SSE) responses?

Use MockAPIClient's requestStream() method. Configure it with an array of Data chunks that simulate the SSE event stream. The ViewModel processes these the same way as real server events.

Testing

How do I run the tests?

In Xcode: Cmd + U. From the terminal: xcodebuild test -project Archon.xcodeproj -scheme Archon -destination 'platform=iOS Simulator,name=iPhone 16'. See Testing guide.

What should I test when adding a new feature?

Test the ViewModel (happy path, error path, edge cases), model decoding (against fixture JSON), and the API client method (correct request construction). UI tests are optional but welcome for critical flows.

How do I add a new mock response?

Add a property to MockAPIClient (e.g., widgetsToReturn) and handle the corresponding path in the request() method. Then set the property in your test's setUp() or test method.

Can I test SwiftUI views?

Yes, using ViewInspector or Xcode's built-in UI testing. For most cases, testing the ViewModel is sufficient since views are thin and declarative. Focus view tests on complex layout logic or accessibility.

Do tests run in CI?

The GitHub Actions workflow runs all tests on every PR. See .github/workflows/test.yml for the configuration. Tests must pass before merging.

Contributing

How do I contribute to Archon?

Fork the repo, create a feature branch, make your changes, and open a PR. See Contributing guide for the full process, code style rules, and PR template.

What's the branch naming convention?

Use feature/short-description, fix/short-description, or docs/short-description. Keep it lowercase with hyphens. Example: feature/add-widget-screen.

Can I work on issues marked "good first issue"?

Absolutely. Those are specifically scoped for new contributors. Comment on the issue to let others know you're working on it, then submit a PR when ready.

What code style does Archon use?

Standard Swift style enforced by SwiftLint. No force unwraps in production code. Meaningful variable names. Keep functions under 40 lines. See Contributing guide for the full style guide.

How long do PR reviews take?

Typically 1-3 business days for initial review. Simple fixes may be reviewed same-day. For larger features, expect iterative feedback over a few days.