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

Accessing Data from a SMART Health Card

At a glance

Item Summary
Purpose Query for and validate a verifiable clinical record.
App architecture A Swift sample with the source-visible chain WWDCDemoAppContentViewHealthKit APIs.
Main patterns No named application pattern supported by the extracted structure
Project style 14 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.
Key frameworks/packages Foundation, SwiftUI, CryptoKit, Compression, HealthKit; these are source dependencies, not architecture labels.

Project structure

Source bundle/
└── Verifiable Clinical Records/
    └── Verifiable Clinical Records/
        ├── WWDCDemoApp.swift
        ├── ContentView.swift
        ├── JWT/
        │   ├── SMARTHealthCardPayload.swift
        │   ├── JWS.swift
        │   ├── CompressionAlgorithm.swift
        │   ├── JWK.swift
        │   ├── JWKError.swift
        │   ├── JWKSet.swift
        │   ├── JWS+Verification.swift
        │   ├── JWSError.swift
        │   └── SignatureAlgorithm.swift
        └── utilities/
            └── Base64URL.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 5 project/configuration file(s) and 17 source declaration(s).

Overall architecture

Reference code

Verifiable Clinical Records/Verifiable Clinical Records/WWDCDemoApp.swift:10 — architecture anchor

@main
struct WWDCDemoApp: App {
    var body: some Scene {
        WindowGroup {
            // Instantiate and display the root view.
            ContentView()
        }
    }
}

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 HealthKit.

Ownership and state

Ownership evidence

Verifiable Clinical Records/Verifiable Clinical Records/JWT/SMARTHealthCardPayload.swift:14 — stored dependency or nearest verified ownership anchor

    public struct VC: Codable {

        public let type: [String]

         public let credentialSubject: CredentialSubject
    }
Owner Object or state Relationship Mutation authority
VC Array (type) owns value state Initialized by the owner; the binding is immutable
VC CredentialSubject (credentialSubject) stores or receives Initialized by the owner; the binding is immutable
VC String (iss) owns value state Initialized by the owner; the binding is immutable
VC Double (nbf) owns value state Initialized by the owner; the binding is immutable

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. Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:64
Suspension boundary await suspension point The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:72

@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

Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:64 — representative execution boundary

            Task(priority: .userInitiated) {
                // ...
                        recordTypes: [.covid19, .immunization],
                        sourceTypes: [.smartHealthCard],
                        predicate: predicate
                // ...
            }

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. Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:17
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWK.swift:8
Source import SwiftUI The cited file imports this module; runtime use and architectural role are not inferred. Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:8
Source import CryptoKit The cited file imports this module; runtime use and architectural role are not inferred. Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWK.swift:9
Source import Compression The cited file imports this module; runtime use and architectural role are not inferred. Verifiable Clinical Records/Verifiable Clinical Records/utilities/Data+Compression.swift:9
Source import HealthKit The cited file imports this module; runtime use and architectural role are not inferred. Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:9

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

Verifiable Clinical Records/Verifiable Clinical Records/WWDCDemoApp.swift:11 — representative type boundary

@main
struct WWDCDemoApp: App {
    // ...
            ContentView()
    // ...
}
Type Responsibility Depends on or conforms to
WWDCDemoApp Application entry and top-level composition App
ContentView User-interface presentation and input forwarding View
SMARTHealthCardPayload Represents a feature value or composable behavior Codable
VC Represents a feature value or composable behavior Codable
CredentialSubject Represents a feature value or composable behavior Codable
JWS Represents a feature value or composable behavior Codable
JWSHeader Represents a feature value or composable behavior Codable
Base64URL Represents a feature value or composable behavior Concrete collaborators/imported frameworks
Base64URLError Represents feature failure conditions Error
CompressionAlgorithm Defines a closed set of feature states or choices String, Codable

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
requestVerifiableHealthRecords (Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:54) 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.
verify (Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:99) 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.
kty (Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWK.swift:13) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
crv (Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWK.swift:14) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.

Reference code

Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift:54 — representative boundary

    private func requestVerifiableHealthRecords() {
        let healthStore = HKHealthStore()
        // ...
    }

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 WWDCDemoApp The source’s App suffix makes this role explicit.
User-interface presentation and input forwarding ContentView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
No named application pattern Verifiable Clinical Records/Verifiable Clinical Records/WWDCDemoApp.swift:10 The verified source directly composes concrete framework types; this document avoids forcing a pattern name.

Naming conventions

  • Types: App: WWDCDemoApp; View: ContentView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: requestVerifiableHealthRecords, verify, split, decode, asP256PublicKey, asRawPublicKey.
  • Files: Verifiable Clinical Records/Verifiable Clinical Records/WWDCDemoApp.swift, Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift, Verifiable Clinical Records/Verifiable Clinical Records/JWT/SMARTHealthCardPayload.swift, Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWS.swift, Verifiable Clinical Records/Verifiable Clinical Records/utilities/Base64URL.swift, Verifiable Clinical Records/Verifiable Clinical Records/JWT/CompressionAlgorithm.swift.

Architecture takeaways

  • WWDCDemoApp is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches SwiftUI, CryptoKit, Compression, HealthKit 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
Verifiable Clinical Records/Verifiable Clinical Records/WWDCDemoApp.swift Cited implementation, WWDCDemoApp
Verifiable Clinical Records/Verifiable Clinical Records/JWT/SMARTHealthCardPayload.swift Cited implementation, SMARTHealthCardPayload, VC, CredentialSubject
Verifiable Clinical Records/Verifiable Clinical Records/ContentView.swift Cited implementation, Task, await suspension point, SwiftUI state property wrapper, SwiftUI, HealthKit, ContentView
Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWK.swift Cited implementation, Foundation, CryptoKit, JWK
Verifiable Clinical Records/Verifiable Clinical Records/utilities/Data+Compression.swift Compression, Feature implementation
Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWS.swift JWS, JWSHeader
Verifiable Clinical Records/Verifiable Clinical Records/utilities/Base64URL.swift Base64URL, Base64URLError
Verifiable Clinical Records/Verifiable Clinical Records/JWT/CompressionAlgorithm.swift CompressionAlgorithm
Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWKError.swift JWKError
Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWKSet.swift JWKSet
Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWS+Verification.swift VerificationError
Verifiable Clinical Records/Verifiable Clinical Records/JWT/JWSError.swift JWSError
Verifiable Clinical Records/Verifiable Clinical Records/JWT/SignatureAlgorithm.swift SignatureAlgorithm
Verifiable Clinical Records/Verifiable Clinical Records/utilities/BlueButtonContent.swift BlueButtonContent