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.

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 var backyard: Backyard
    public var visitingBird: Bird?
    public var visitingBirdDuration: TimeInterval?
    public var timeInterval: TimeInterval
    public var date: Date
    public var notableEvents: Set<NotableEvent> = []
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.

Class and protocol design

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

struct BackyardBirdsWatchApp: App {
    // ...
}
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 BackyardBirdsWatchApp
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
Session 10031/End/Backyard Birds Watch App/BackyardBirdsUI/BackyardUnavailableView.swift BackyardUnavailableView, BackyardUnavailableView_Previews
Session 10031/End/Backyard Birds Watch App/BackyardBirdsUI/BackyardView.swift BackyardView, BackyardView_Previews
Session 10031/End/Backyard Birds Watch App/BackyardBirdsUI/BirdHouseView.swift BirdHouseView, BirdHouseView_Previews