Sample CodeiOS, iPadOS, Mac Catalyst, macOS, watchOSReviewed 2026-07-21View on Apple Developer

Updating your app and widgets for watchOS 10

At a glance

Item Summary
Purpose Integrate SwiftUI elements and watch-specific features, and build widgets for the Smart Stack.
App architecture A Swift sample bundle with entry-bearing project variants Session 10029, Session 10031, each leading to SwiftUI / SwiftData APIs.
Main patterns No named application pattern supported by the extracted structure
Project style 207 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: Task, await suspension point; none alone proves a background thread.
State/event model Source-visible mechanisms: SwiftUI state property wrapper, ObservableObject, @Published.
Key frameworks/packages SwiftUI, Foundation, SwiftData, BackyardBirdsData, OSLog, Local package ../BackyardBirdsData, Local package ../LayeredArtworkLibrary; these are source dependencies, not architecture labels.

Project structure

Source bundle/
├── Session 10029/
│   ├── End/
│   │   ├── Watch/
│   │   │   └── BackyardBirdsWatchApp.swift
│   │   └── Widgets/
│   │       ├── WidgetsBundle.swift
│   │       └── BackyardVisitor/
│   │           └── BackyardVisitorsWidget.swift
│   └── Start/
│       ├── Watch/
│       │   └── BackyardBirdsWatchApp.swift
│       └── Widgets/
│           └── WidgetsBundle.swift
└── Session 10031/
    ├── End/
    │   └── Backyard Birds Watch App/
    │       ├── BackyardBirdsWatchApp.swift
    │       └── BackyardBirdsUI/
    │           ├── BackyardUnavailableView.swift
    │           ├── BackyardView.swift
    │           ├── BirdHouseView.swift
    │           ├── BirdView.swift
    │           └── HabitatGaugeView.swift
    └── Start/
        └── Backyard Birds Watch App/
            └── BackyardBirdsWatchApp.swift

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 17 project/configuration file(s) and 214 source declaration(s).

Overall architecture

Reference code

Session 10029/End/Watch/BackyardBirdsWatchApp.swift:12 — architecture anchor

@main
struct BackyardBirdsWatchApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .backyardBirdsDataContainer()
        }
    }
}

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

Ownership evidence

Session 10029/End/BackyardBirdsData/Backyards/BackyardSnapshot.swift:11 — stored dependency or nearest verified ownership anchor

public struct BackyardSnapshot {
    public var backyard: Backyard
    // ...
}
Owner Object or state Relationship Mutation authority
BackyardSnapshot Backyard (backyard) stores or receives App/module collaborators
BackyardSnapshot Bird (visitingBird) stores or receives App/module collaborators
BackyardSnapshot TimeInterval (visitingBirdDuration) stores or receives App/module collaborators
BackyardSnapshot TimeInterval (timeInterval) stores or receives 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
Task creation Task The source creates an unstructured task; surrounding context determines inherited actor isolation. Session 10029/End/BackyardBirdsData/General/ModelPreview.swift:44
Suspension boundary await suspension point The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. Session 10029/End/BackyardBirdsData/General/ModelPreview.swift:45

@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

Session 10029/End/BackyardBirdsData/General/ModelPreview.swift:44 — representative execution boundary

                    Task {
                        try await Task.sleep(for: .seconds(1))
                        waitedToShowIssue = true
                    }

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. Session 10029/End/BackyardBirdsData/General/BackyardBirdsDataContainer.swift:26
State propagation ObservableObject ObservableObject supplies an observation contract. Session 10031/End/Backyard Birds Watch App/BackyardBirdsData/Backyard.swift:11
State propagation @Published A published property can emit owner-controlled changes. Session 10031/End/Backyard Birds Watch App/BackyardBirdsData/BackyardsData.swift:14
Package manifest Local package ../BackyardBirdsData The manifest declares a local path dependency; direct target use and transitive position are not inferred. Session 10029/End/BackyardBirdsUI/Package.swift:29
Package manifest Local package ../LayeredArtworkLibrary The manifest declares a local path dependency; direct target use and transitive position are not inferred. Session 10029/End/BackyardBirdsUI/Package.swift:30
Source import SwiftUI The cited file imports this module; runtime use and architectural role are not inferred. Session 10029/End/BackyardBirdsData/Backyards/BackyardTimeOfDay.swift:9
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. Session 10029/End/BackyardBirdsData/Account/Account+DataGeneration.swift:8
Source import SwiftData The cited file imports this module; runtime use and architectural role are not inferred. Session 10029/End/BackyardBirdsData/Account/Account+DataGeneration.swift:10

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

Session 10029/End/Watch/BackyardBirdsWatchApp.swift:13 — representative type boundary

@main
struct BackyardBirdsWatchApp: App {
    // ...
            ContentView()
    // ...
}
Type Responsibility Depends on or conforms to
BackyardBirdsWatchApp Application entry and top-level composition App
BackyardBirdsWatchApp Application entry and top-level composition App
BackyardBirdsWatchApp Application entry and top-level composition App
BackyardBirdsWatchApp Application entry and top-level composition App
Provider Supplies a capability or framework resource AppIntentTimelineProvider
BackyardBirdsWidgetEntryView User-interface presentation and input forwarding View
RectangularBackyardView User-interface presentation and input forwarding View
BackyardUnavailableView User-interface presentation and input forwarding View
BackyardView User-interface presentation and input forwarding View
BirdHouseView User-interface presentation and input forwarding 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
logger (Session 10029/End/BackyardBirdsData/Account/Account+DataGeneration.swift:12) 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.
logger (Session 10029/End/BackyardBirdsData/Account/Account.swift:13) 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.
id (Session 10029/End/BackyardBirdsData/Account/Account.swift:17) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
bird (Session 10029/End/BackyardBirdsData/Account/Account.swift:18) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.

Reference code

Session 10029/End/BackyardBirdsData/Account/Account+DataGeneration.swift:12 — representative boundary

private let logger = Logger(subsystem: "BackyardBirdsData", category: "Account Generation")

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 BackyardBirdsWatchApp The source’s App suffix makes this role explicit.
Generates feature data or resources SeededRandomGenerator The source’s Generator suffix makes this role explicit.
Supplies a capability or framework resource Provider The source’s Provider suffix makes this role explicit.
User-interface presentation and input forwarding BackyardBirdsWidgetEntryView, BackyardSkyView, BackyardTabView, BackyardUnavailableView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
No named application pattern Session 10029/End/Watch/BackyardBirdsWatchApp.swift:12 The verified source directly composes concrete framework types; this document avoids forcing a pattern name.

Naming conventions

  • Types: App: BackyardBirdsWatchApp; Generator: SeededRandomGenerator; Provider: Provider; View: BackyardBirdsWidgetEntryView, BackyardSkyView, BackyardTabView, BackyardUnavailableView, BackyardView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: placeholder, snapshot, timeline, recommendations.
  • Files: Session 10029/End/Watch/BackyardBirdsWatchApp.swift, Session 10029/Start/Watch/BackyardBirdsWatchApp.swift, Session 10031/End/Backyard Birds Watch App/BackyardBirdsWatchApp.swift, Session 10031/Start/Backyard Birds Watch App/BackyardBirdsWatchApp.swift, Session 10029/End/Widgets/WidgetsBundle.swift, Session 10029/Start/Widgets/WidgetsBundle.swift.

Architecture takeaways

  • BackyardBirdsWatchApp is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches SwiftUI, SwiftData, BackyardBirdsData, LayeredArtworkLibrary 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
Session 10029/End/Watch/BackyardBirdsWatchApp.swift Cited implementation, BackyardBirdsWatchApp
Session 10029/End/BackyardBirdsData/Backyards/BackyardSnapshot.swift Cited implementation, BackyardSnapshot, NotableEvent
Session 10029/End/BackyardBirdsData/Account/Account+DataGeneration.swift Cited implementation, Foundation, SwiftData
Session 10029/End/BackyardBirdsData/Account/Account.swift Cited implementation, Account
Session 10029/End/BackyardBirdsData/General/ModelPreview.swift Task, await suspension point, ModelPreview, PreviewContentView
Session 10029/End/BackyardBirdsData/General/BackyardBirdsDataContainer.swift SwiftUI state property wrapper, BackyardBirdsDataContainerViewModifier, GenerateDataViewModifier
Session 10031/End/Backyard Birds Watch App/BackyardBirdsData/Backyard.swift ObservableObject, Backyard, BackyardBird
Session 10031/End/Backyard Birds Watch App/BackyardBirdsData/BackyardsData.swift @Published, BackyardsData, SeededRandomGenerator
Session 10029/End/BackyardBirdsUI/Package.swift Cited implementation
Session 10029/End/BackyardBirdsData/Backyards/BackyardTimeOfDay.swift SwiftUI, BackyardTimeOfDay
Session 10029/Start/Watch/BackyardBirdsWatchApp.swift BackyardBirdsWatchApp
Session 10031/End/Backyard Birds Watch App/BackyardBirdsWatchApp.swift BackyardBirdsWatchApp
Session 10031/Start/Backyard Birds Watch App/BackyardBirdsWatchApp.swift BackyardBirdsWatchApp
Session 10029/End/Widgets/WidgetsBundle.swift WidgetsBundle
Session 10029/Start/Widgets/WidgetsBundle.swift WidgetsBundle
Session 10029/End/Widgets/BackyardVisitor/BackyardVisitorsWidget.swift Provider, SimpleEntry, BackyardBirdsWidgetEntryView, BackyardVisitorsWidget, RectangularBackyardView