Create accessible experiences for watchOS
At a glance
| Item | Summary |
|---|---|
| Purpose | Learn how to make your watchOS app more accessible. |
| App architecture | A Swift sample with the source-visible chain PlantCareApp → PlantContentView → SwiftUI / ClockKit APIs. |
| Main patterns | View-controller organization, Delegate or data-source callbacks, SwiftUI environment injection, Binding-based state propagation, Publisher-backed observable state |
| Project style | 6 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
├── PlantCare/
│ ├── PlantCare WatchKit Extension/
│ │ ├── PlantCareApp.swift
│ │ ├── PlantCellView.swift
│ │ ├── PlantEditView.swift
│ │ ├── PlantContentView.swift
│ │ ├── ComplicationController.swift
│ │ ├── PlantData.swift
│ │ └── Info.plist
│ └── PlantCare.xcodeproj/
│ ├── .xcodesamplecode.plist
│ └── project.pbxproj
└── Configuration/
└── SampleCode.xcconfig
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 4 project/configuration file(s) and 19 source declaration(s).
Overall architecture
flowchart LR
N1["PlantCareApp"]
N2["PlantContentView"]
N3["SwiftUI / ClockKit APIs"]
N1 --> N2
N2 --> N3
Reference code
PlantCare/PlantCare WatchKit Extension/PlantCareApp.swift:10 — architecture anchor
@main
struct PlantCareApp: App {
// ...
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into watchOS-Apps.
Ownership and state
classDiagram
PlantCellView o-- PlantData : plantData
PlantCellView o-- Plant : plant
PlantContainerView o-- Plant : plant
PlantViewHorizontal o-- Plant : plant
Ownership evidence
PlantCare/PlantCare WatchKit Extension/PlantCellView.swift:11 — stored dependency or nearest verified ownership anchor
@EnvironmentObject var plantData: PlantData
@State var isShowingEditView = false
var plant: Plant
var plantIndex: Int {
plantData.plants.firstIndex(where: { $0.id == plant.id })!
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
PlantCellView |
PlantData (plantData) |
receives environment-provided state | The environment provider is authoritative |
PlantCellView |
Plant (plant) |
stores or receives | App/module collaborators |
PlantContainerView |
Plant (plant) |
borrows mutable state | The upstream binding owner is authoritative |
PlantViewHorizontal |
Plant (plant) |
borrows mutable state | The upstream binding owner is authoritative |
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.
Class and protocol design
PlantCare/PlantCare WatchKit Extension/PlantCareApp.swift:11 — representative type boundary
struct PlantCareApp: App {
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
PlantCareApp |
Application entry and top-level composition | App |
PlantCellView |
User-interface presentation and input forwarding | View |
PlantContainerView |
User-interface presentation and input forwarding | View |
PlantEditView |
User-interface presentation and input forwarding | View |
PlantContentView |
User-interface presentation and input forwarding | View |
ComplicationController |
View lifecycle, callbacks, and feature coordination | NSObject, CLKComplicationDataSource |
PlantViewHorizontal |
Represents a feature value or composable behavior | View |
PlantViewVertical |
Represents a feature value or composable behavior | View |
PlantImage |
Represents a feature value or composable behavior | View |
PlantTaskLabel |
Represents a feature value or composable behavior | View |
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 |
|---|---|---|---|
createTimelineEntry (PlantCare/PlantCare WatchKit Extension/ComplicationController.swift:78) |
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. |
createTemplate (PlantCare/PlantCare WatchKit Extension/ComplicationController.swift:83) |
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. |
createModularSmallTemplate (PlantCare/PlantCare WatchKit Extension/ComplicationController.swift:118) |
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. |
createModularLargeTemplate (PlantCare/PlantCare WatchKit Extension/ComplicationController.swift:133) |
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. |
Reference code
PlantCare/PlantCare WatchKit Extension/ComplicationController.swift:78 — representative boundary
private func createTimelineEntry(forComplication complication: CLKComplication, date: Date) -> CLKComplicationTimelineEntry {
let template = createTemplate(forComplication: complication, date: date)
return CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
}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 | PlantCareApp |
The source’s App suffix makes this role explicit. |
| View lifecycle, callbacks, and feature coordination | ComplicationController |
The source’s Controller suffix makes this role explicit. |
| User-interface presentation and input forwarding | PlantCellView, PlantContainerView, PlantContentView, PlantEditView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| View-controller organization | PlantCare/PlantCare WatchKit Extension/ComplicationController.swift:9 |
A controller is the verified coordination boundary; this is MVC-style only where a separate model is present. |
| Delegate or data-source callbacks | PlantCare/PlantCare WatchKit Extension/ComplicationController.swift:9 |
Callback protocols invert event delivery back into the sample’s owner. |
| SwiftUI environment injection | PlantCare/PlantCare WatchKit Extension/PlantCellView.swift:11 |
The environment supplies state or a capability without threading it through every initializer. |
| Binding-based state propagation | PlantCare/PlantCare WatchKit Extension/PlantCellView.swift:36 |
A binding exposes controlled read/write access while the upstream owner remains authoritative. |
| Publisher-backed observable state | PlantCare/PlantCare WatchKit Extension/PlantData.swift:159 |
Published properties notify observers while mutation remains with the state object. |
Naming conventions
- Types: App: PlantCareApp; Controller: ComplicationController; View: PlantCellView, PlantContainerView, PlantContentView, PlantEditView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
getComplicationDescriptors,handleSharedComplicationDescriptors,getTimelineEndDate,getPrivacyBehavior,getCurrentTimelineEntry,getTimelineEntries,getLocalizableSampleTemplate,createTimelineEntry. - Files:
PlantCare/PlantCare WatchKit Extension/PlantCareApp.swift,PlantCare/PlantCare WatchKit Extension/PlantCellView.swift,PlantCare/PlantCare WatchKit Extension/PlantEditView.swift,PlantCare/PlantCare WatchKit Extension/PlantContentView.swift,PlantCare/PlantCare WatchKit Extension/ComplicationController.swift,PlantCare/PlantCare WatchKit Extension/PlantData.swift.
Architecture takeaways
PlantCareAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches SwiftUI, ClockKit 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 |
|---|---|
PlantCare/PlantCare WatchKit Extension/PlantCareApp.swift |
PlantCareApp |
PlantCare/PlantCare WatchKit Extension/PlantCellView.swift |
PlantCellView, PlantContainerView, PlantViewHorizontal, PlantViewVertical, PlantImage, PlantTaskLabel, PlantButton, PlantTaskList, PlantTaskButtons, PlantCellView_Previews |
PlantCare/PlantCare WatchKit Extension/PlantEditView.swift |
PlantEditView, PlantTaskFrequency, CustomCounter, PlantEditView_Previews |
PlantCare/PlantCare WatchKit Extension/PlantContentView.swift |
PlantContentView, ContentView_Previews |
PlantCare/PlantCare WatchKit Extension/ComplicationController.swift |
ComplicationController |
PlantCare/PlantCare WatchKit Extension/PlantData.swift |
SunlightLevel, Plant, PlantTask, PlantData |