Defining your app’s Focus filter
At a glance
| Item | Summary |
|---|---|
| Purpose | Customize your app’s behavior to reflect the device’s current Focus. |
| App architecture | A Swift sample bundle with entry-bearing project variants ExampleAppIntentsExtension, ExampleChatApp, each leading to AppIntents APIs. |
| Main patterns | Model-View-ViewModel, Repository |
| Project style | 8 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
| Execution model | Source-visible boundaries: async declaration or closure, Sendable or @Sendable; none alone proves a background thread. |
| State/event model | Source-visible mechanisms: SwiftUI state property wrapper. |
| Key frameworks/packages | AppIntents, OSLog, SwiftUI, Foundation; these are source dependencies, not architecture labels. |
Project structure
Source bundle/
├── ExampleChatApp/
│ ├── ExampleChatApp.swift
│ └── ContentView.swift
├── ExampleAppIntentsExtension/
│ ├── ExampleAppIntentsExtension.swift
│ ├── ExampleFocusFilter.swift
│ ├── ExampleAppIntentsExtension.entitlements
│ └── Info.plist
├── Shared/
│ ├── AppDataModel.swift
│ ├── Repository.swift
│ ├── AccountEntity.swift
│ └── AccountEntityQuery.swift
├── Configuration/
│ └── SampleCode.xcconfig
└── ExampleChatApp.xcodeproj/
└── .xcodesamplecode.plist
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 6 project/configuration file(s) and 10 source declaration(s).
Overall architecture
flowchart LR
Bundle["Sample bundle"]
V1["ExampleAppIntentsExtension"]
V2["ExampleChatApp"]
Boundary["AppIntents APIs"]
Bundle --> V1
V1 --> Boundary
Bundle --> V2
V2 --> Boundary
Reference code
ExampleChatApp/ExampleChatApp.swift:10 — architecture anchor
@main
struct ExampleChatApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}Interpretation
The branches represent separate entry-bearing project variants in the downloaded bundle, not runtime calls between those variants. Each branch is intentionally collapsed at the documented framework boundary; the detailed target-local flow remains in the cited files. Ownership is claimed only where the next section cites a stored property or assignment.
Ownership and state
classDiagram
AppDataModel o-- Alwaysusedarkmode : alwaysUseDarkMode
AppDataModel o-- Status : status
AppDataModel o-- Selectedaccountid : selectedAccountID
ContentView *-- Data : appData
Ownership evidence
Shared/AppDataModel.swift:14 — stored dependency or nearest verified ownership anchor
struct AppDataModel: Codable {
// ...
self.alwaysUseDarkMode = alwaysUseDarkMode
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
AppDataModel |
Alwaysusedarkmode (alwaysUseDarkMode) |
stores or receives | App/module collaborators |
AppDataModel |
Status (status) |
stores or receives | App/module collaborators |
AppDataModel |
Selectedaccountid (selectedAccountID) |
stores or receives | App/module collaborators |
ContentView |
Data (appData) |
owns value state | App/module collaborators |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Concurrency, scheduling, and thread safety
Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.
| Concern | Source mechanism | Verified placement or handoff | Evidence |
|---|---|---|---|
| Suspension boundary | async declaration or closure |
The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. | ExampleAppIntentsExtension/ExampleFocusFilter.swift:78 |
| Transfer contract | Sendable or @Sendable |
The source declares a sendability boundary; this alone does not synchronize mutable state. | Shared/Repository.swift:12 |
@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.
Reference code
ExampleAppIntentsExtension/ExampleFocusFilter.swift:78 — representative execution boundary
static func suggestedFocusFilters(for context: FocusFilterSuggestionContext) async -> [ExampleFocusFilter] {
let workFilter = ExampleFocusFilter()
// ...
}State propagation, frameworks, and dependencies
Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.
| Category | Mechanism or module | Verified role | Evidence |
|---|---|---|---|
| State propagation | SwiftUI state property wrapper |
A SwiftUI property wrapper supplies or observes UI state. | ExampleChatApp/ContentView.swift:14 |
| Source import | AppIntents |
The cited file imports this module; runtime use and architectural role are not inferred. | ExampleAppIntentsExtension/ExampleAppIntentsExtension.swift:8 |
| Source import | OSLog |
The cited file imports this module; runtime use and architectural role are not inferred. | ExampleAppIntentsExtension/ExampleAppIntentsExtension.swift:7 |
| Source import | SwiftUI |
The cited file imports this module; runtime use and architectural role are not inferred. | ExampleChatApp/ContentView.swift:8 |
| Source import | Foundation |
The cited file imports this module; runtime use and architectural role are not inferred. | Shared/AppDataModel.swift:8 |
receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.
Class and protocol design
ExampleChatApp/ExampleChatApp.swift:11 — representative type boundary
@main
struct ExampleChatApp: App {
// ...
ContentView()
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
ExampleChatApp |
Application entry and top-level composition | App |
AppDataModel |
Feature data or observable state | Codable |
ContentView |
User-interface presentation and input forwarding | View |
ContentViewModel |
UI-facing state and feature coordination | Concrete collaborators/imported frameworks |
Repository |
Data access boundary | Sendable |
ExampleAppIntentsExtension |
Represents a feature value or composable behavior | AppIntentsExtension |
RepositoryError |
Represents feature failure conditions | Error, CustomLocalizedStringResourceConvertible |
ExampleFocusFilter |
Represents a feature value or composable behavior | SetFocusFilterIntent |
AccountEntity |
Represents feature data | AppEntity |
AccountEntityQuery |
Represents a feature value or composable behavior | EntityQuery |
No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
primaryText (ExampleAppIntentsExtension/ExampleFocusFilter.swift:43) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: keep state mutation or dependency lifetime inside the owning implementation. |
secondaryText (ExampleAppIntentsExtension/ExampleFocusFilter.swift:50) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: keep state mutation or dependency lifetime inside the owning implementation. |
titleAndSubtitleView (ExampleChatApp/ContentView.swift:45) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: hide an implementation step that is not part of the collaboration surface. |
ExampleAppIntentsExtension (ExampleAppIntentsExtension/ExampleAppIntentsExtension.swift:10) |
implicit internal |
No explicit modifier means the Swift declaration is internal to the module. | Inference: app-target collaboration needs no exported library surface. |
Reference code
ExampleAppIntentsExtension/ExampleFocusFilter.swift:43 — representative boundary
private var primaryText: String {
guard let accountName = self.account?.displayName else {
return "Account: none selected"
}
return "Account: \(accountName)"
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Application entry and top-level composition | ExampleChatApp |
The source’s App suffix makes this role explicit. |
| Feature data or observable state | AppDataModel |
The source’s Model suffix makes this role explicit. |
| Data access boundary | Repository |
The source’s Repository suffix makes this role explicit. |
| User-interface presentation and input forwarding | ContentView |
The source’s View suffix makes this role explicit. |
| UI-facing state and feature coordination | ContentViewModel |
The source’s ViewModel suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Model-View-ViewModel | ExampleChatApp/ContentView.swift:52 |
Role-named view models keep UI-facing state or coordination outside view declarations. |
| Repository | Shared/Repository.swift:12 |
A repository-named type creates a data-access boundary. |
Naming conventions
- Types: App: ExampleChatApp; Model: AppDataModel; Repository: Repository; View: ContentView; ViewModel: ContentViewModel.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
titleAndSubtitleView,updateAppDataModelStore,accountEntity,suggestedFocusFilters,perform,entities,suggestedEntities. - Files:
ExampleChatApp/ExampleChatApp.swift,ExampleAppIntentsExtension/ExampleAppIntentsExtension.swift,Shared/AppDataModel.swift,ExampleChatApp/ContentView.swift,Shared/Repository.swift,ExampleAppIntentsExtension/ExampleFocusFilter.swift.
Architecture takeaways
ExampleChatAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches AppIntents, SwiftUI through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- The source does not justify labeling the design protocol-oriented.
Source map
| Source file | Relevant symbols |
|---|---|
ExampleChatApp/ExampleChatApp.swift |
Cited implementation, ExampleChatApp |
Shared/AppDataModel.swift |
Cited implementation, Foundation, AppDataModel |
ExampleAppIntentsExtension/ExampleFocusFilter.swift |
Cited implementation, async declaration or closure, ExampleFocusFilter |
ExampleChatApp/ContentView.swift |
Cited implementation, ContentViewModel, SwiftUI state property wrapper, SwiftUI, ContentView, ContentView_Previews |
ExampleAppIntentsExtension/ExampleAppIntentsExtension.swift |
Cited implementation, AppIntents, OSLog, ExampleAppIntentsExtension |
Shared/Repository.swift |
Repository, Sendable or @Sendable, RepositoryError |
Shared/AccountEntity.swift |
AccountEntity |
Shared/AccountEntityQuery.swift |
AccountEntityQuery |