Sample CodeiOS, iPadOS, Mac CatalystReviewed 2026-07-21View on Apple Developer

Building an App to Notify Users of COVID-19 Exposure

At a glance

Item Summary
Purpose Inform people when they may have been exposed to COVID-19.
App architecture A Swift sample bundle with entry-bearing project variants ExposureNotificationApp-iOS12, ExposureNotificationApp, each leading to ExposureNotification APIs.
Main patterns View-controller organization, Delegate or data-source callbacks, Central store
Project style 33 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.

Project structure

Source bundle/
├── ExposureNotificationApp-iOS12/
│   └── AppDelegate.swift
├── ExposureNotificationApp/
│   ├── Custom View Controllers/
│   │   ├── ExposureDetailsViewController.swift
│   │   ├── OnboardingViewController.swift
│   │   ├── StepViewController.swift
│   │   ├── TestVerificationViewController.swift
│   │   ├── ExposureNotificationsInfoViewController.swift
│   │   ├── ExposuresViewController.swift
│   │   ├── NotifyOthersViewController.swift
│   │   └── TestResultDetailsViewController.swift
│   └── Developer/
│       ├── DeveloperDiagnosisKeysViewController.swift
│       └── DeveloperViewController.swift
└── Common/
    └── Model/
        └── LocalStore.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 101 source declaration(s).

Overall architecture

Reference code

ExposureNotificationApp-iOS12/AppDelegate.swift:12 — architecture anchor

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
}

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

ExposureNotificationApp-iOS12/AppDelegate.swift:17 — stored dependency or nearest verified ownership anchor

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
    var window: UIWindow?
    // ...
}
Owner Object or state Relationship Mutation authority
AppDelegate UIWindow (window) stores or receives App/module collaborators
ExposureDetailsViewController RelativeDateTimeFormatter (relativeDateFormatter) stores or receives Initialized by the owner; the binding is immutable
ExposureDetailsCell UILabel (headerLabel) stores or receives App/module collaborators
ExposureDetailsCell UILabel (diagnosisVerificationLabel) 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

ExposureNotificationApp-iOS12/AppDelegate.swift:13 — representative type boundary

class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
}
Type Responsibility Depends on or conforms to
AppDelegate Receives callback-driven events UIResponder, UIApplicationDelegate
AppDelegate Receives callback-driven events UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate
ExposureDetailsViewController View lifecycle, callbacks, and feature coordination ValueStepViewController<Exposure, ExposureDetailsViewController.CustomItem>
ExposureLearnMoreViewController View lifecycle, callbacks, and feature coordination StepViewController
OnboardingViewController View lifecycle, callbacks, and feature coordination StepNavigationController
WelcomeViewController View lifecycle, callbacks, and feature coordination StepViewController
EnableExposureNotificationsViewController View lifecycle, callbacks, and feature coordination StepViewController
RecommendExposureNotificationsViewController View lifecycle, callbacks, and feature coordination StepViewController
RecommendExposureNotificationsSettingsViewController View lifecycle, callbacks, and feature coordination StepViewController
RecommendPushNotificationsViewController View lifecycle, callbacks, and feature coordination StepViewController

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
segueRowData (ExposureNotificationApp-iOS12/View Controllers/MainViewController.swift:16) 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.
sectionTitles (ExposureNotificationApp-iOS12/View Controllers/MainViewControllerData.swift:49) fileprivate Use is restricted to this source file. Inference: share with same-file helpers or extensions without exposing the symbol module-wide.
statusSections (ExposureNotificationApp-iOS12/View Controllers/MainViewControllerData.swift:74) fileprivate Use is restricted to this source file. Inference: share with same-file helpers or extensions without exposing the symbol module-wide.
shareSections (ExposureNotificationApp-iOS12/View Controllers/MainViewControllerData.swift:122) fileprivate Use is restricted to this source file. Inference: share with same-file helpers or extensions without exposing the symbol module-wide.

Reference code

ExposureNotificationApp-iOS12/View Controllers/MainViewController.swift:16 — representative boundary

class MainViewController: UITableViewController {
    // ...
    private var segueRowData: TableRowData?
    // ...
}

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
View lifecycle, callbacks, and feature coordination AboutTestIdentifiersViewController, BeforeYouGetStartedViewController, ContentViewController, CustomStepViewController The source’s Controller suffix makes this role explicit.
Supplies data through a callback contract DataSource The source’s DataSource suffix makes this role explicit.
Receives callback-driven events AppDelegate, SceneDelegate The source’s Delegate suffix makes this role explicit.
Long-lived feature or framework coordination ExposureManager The source’s Manager suffix makes this role explicit.
Centralized state or persistence access LocalStore The source’s Store suffix makes this role explicit.
User-interface presentation and input forwarding DeveloperQRCodeScannerView, EntryStackView, EntryView, RequirementView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
View-controller organization ExposureNotificationApp/Custom View Controllers/TestVerificationViewController.swift:146 A controller is the verified coordination boundary; this is MVC-style only where a separate model is present.
Delegate or data-source callbacks ExposureNotificationApp-iOS12/AppDelegate.swift:13 Callback protocols invert event delivery back into the sample’s owner.
Central store Common/Model/LocalStore.swift:63 A store-named type centralizes feature state or persistence.

Naming conventions

  • Types: Controller: AboutTestIdentifiersViewController, BeforeYouGetStartedViewController, ContentViewController, CustomStepViewController, DeveloperDiagnosisKeysViewController; DataSource: DataSource; Delegate: AppDelegate, SceneDelegate; Manager: ExposureManager; Store: LocalStore; View: DeveloperQRCodeScannerView, EntryStackView, EntryView, RequirementView, TableHeaderView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: application, viewDidLoad, tableView, modifySnapshot, learnMore, enableExposureNotifications, enablePushNotifications, viewDidAppear.
  • Files: ExposureNotificationApp-iOS12/AppDelegate.swift, ExposureNotificationApp/Custom View Controllers/ExposureDetailsViewController.swift, ExposureNotificationApp/Custom View Controllers/OnboardingViewController.swift, ExposureNotificationApp/Custom View Controllers/StepViewController.swift, ExposureNotificationApp/Custom View Controllers/TestVerificationViewController.swift, ExposureNotificationApp/Developer/DeveloperDiagnosisKeysViewController.swift.

Architecture takeaways

  • AppDelegate is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches UIKit, ExposureNotification, BackgroundTasks, UserNotifications 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
ExposureNotificationApp-iOS12/AppDelegate.swift AppDelegate
ExposureNotificationApp/Custom View Controllers/ExposureDetailsViewController.swift ExposureDetailsViewController, CustomItem, ExposureDetailsCell, ExposureNextStepsCell, ExposureFootnoteCell, ExposureLearnMoreViewController
ExposureNotificationApp/Custom View Controllers/OnboardingViewController.swift OnboardingViewController, WelcomeViewController, EnableExposureNotificationsViewController, RecommendExposureNotificationsViewController, RecommendExposureNotificationsSettingsViewController, RecommendPushNotificationsViewController, NotifyingOthersViewController
ExposureNotificationApp/Custom View Controllers/StepViewController.swift Step, BarButton, Button, StepNavigationController, CustomStepViewController, Section, Item, StepViewController, StepOptionalSeparatorCell, StepTitleCell, StepTextCell, ValueStepViewController
ExposureNotificationApp/Custom View Controllers/TestVerificationViewController.swift TestVerificationViewController, TestStepViewController, BeforeYouGetStartedViewController, TestIdentifierViewController, AboutTestIdentifiersViewController, TestAdministrationDateViewController, CustomItem, ReviewViewController, CustomItem, FinishedViewController, TestAdministrationDatePickerCell
ExposureNotificationApp/Developer/DeveloperDiagnosisKeysViewController.swift DeveloperDiagnosisKeysViewController, Section, Item, DataSource, DeveloperQRCodeViewController, DeveloperQRCodeScannerViewController, DeveloperQRCodeScannerView
Common/Model/LocalStore.swift Exposure, TestResult, Persisted, LocalStore
ExposureNotificationApp/Custom View Controllers/ExposureNotificationsInfoViewController.swift ExposureNotificationsInfoViewController, ContentViewController, ExposureNotificationsPrivacyViewController, ContentViewController
ExposureNotificationApp/Custom View Controllers/ExposuresViewController.swift ExposuresViewController, Section, Item, DataSource
ExposureNotificationApp/Custom View Controllers/NotifyOthersViewController.swift NotifyOthersViewController, Section, Item, DataSource