Implementing Wallet Extensions
At a glance
| Item | Summary |
|---|---|
| Purpose | Support adding an issued card to Apple Pay from directly within Apple Wallet using Wallet Extensions. |
| App architecture | A Swift sample with the source-visible chain ImplementingWalletExtensionsSampleApp → LoginView → MockWatchConnectivitySession → PassKit APIs. |
| Main patterns | Delegate or data-source callbacks |
| Project style | 12 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
| Execution model | No structured execution marker indexed; callback threading requires source review. |
| State/event model | Source-visible mechanisms: SwiftUI state property wrapper. |
| Key frameworks/packages | PassKit, SwiftUI, os, WatchConnectivity, Foundation; these are source dependencies, not architecture labels. |
Project structure
Source bundle/
├── ImplementingWalletExtensionsSampleApp/
│ ├── ImplementingWalletExtensionsSampleApp.swift
│ └── LoginView.swift
├── WUIExt/
│ ├── WUIExtView.swift
│ └── WUIExtHandler.swift
├── ImplementingWalletExtensionsSampleAppTests/
│ ├── TestModels.swift
│ ├── WNonUIExtHandler.swift
│ ├── WatchConnectivitySession.swift
│ └── WNonUIExtHandlerTests.swift
└── WNonUIExt/
├── Models/
│ ├── WatchConnectivitySession.swift
│ ├── AppGroupManager.swift
│ └── MockClasses.swift
└── WNonUIExtHandler.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 9 project/configuration file(s) and 20 source declaration(s).
Overall architecture
flowchart LR
N1["ImplementingWalletExtensionsSampleApp"]
N2["LoginView"]
N3["MockWatchConnectivitySession"]
N4["PassKit APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
Reference code
ImplementingWalletExtensionsSampleApp/ImplementingWalletExtensionsSampleApp.swift:10 — architecture anchor
@main
struct ImplementingWalletExtensionsSampleApp: App {
var body: some Scene {
WindowGroup {
LoginView()
}
}
}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 PassKit (Apple Pay and Wallet).
Ownership and state
classDiagram
LoginView *-- String : username
LoginView *-- String : password
WUIExtView o-- Callback : completionHandler
WUIExtView *-- String : username
Ownership evidence
ImplementingWalletExtensionsSampleApp/LoginView.swift:11 — stored dependency or nearest verified ownership anchor
struct LoginView: View {
@State var username: String = ""
@State var password: String = ""
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
LoginView |
String (username) |
owns wrapper-managed state | App/module collaborators |
LoginView |
String (password) |
owns wrapper-managed state | App/module collaborators |
WUIExtView |
Callback (completionHandler) |
stores a callback | App/module collaborators |
WUIExtView |
String (username) |
owns wrapper-managed state | 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.
No source-visible execution, scheduling, or synchronization boundary was found in the indexed source.
@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.
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. | ImplementingWalletExtensionsSampleApp/LoginView.swift:11 |
| Source import | PassKit |
The cited file imports this module; runtime use and architectural role are not inferred. | ImplementingWalletExtensionsSampleAppTests/TestModels.swift:9 |
| Source import | SwiftUI |
The cited file imports this module; runtime use and architectural role are not inferred. | ImplementingWalletExtensionsSampleApp/ImplementingWalletExtensionsSampleApp.swift:8 |
| Source import | os |
The cited file imports this module; runtime use and architectural role are not inferred. | ImplementingWalletExtensionsSampleAppTests/TestModels.swift:8 |
| Source import | WatchConnectivity |
The cited file imports this module; runtime use and architectural role are not inferred. | ImplementingWalletExtensionsSampleAppTests/WatchConnectivitySession.swift:8 |
| Source import | Foundation |
The cited file imports this module; runtime use and architectural role are not inferred. | WNonUIExt/Models/AppGroupManager.swift:8 |
| Source import | UIKit |
The cited file imports this module; runtime use and architectural role are not inferred. | WUIExt/WUIExtHandler.swift:8 |
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
ImplementingWalletExtensionsSampleApp/ImplementingWalletExtensionsSampleApp.swift:11 — representative type boundary
@main
struct ImplementingWalletExtensionsSampleApp: App {
// ...
LoginView()
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
ImplementingWalletExtensionsSampleApp |
Application entry and top-level composition | App |
LoginView |
User-interface presentation and input forwarding | View |
WUIExtView |
User-interface presentation and input forwarding | View |
MockWatchConnectivitySession |
Owns a session-scoped interaction | WatchConnectivitySession |
WatchConnectivitySession |
Owns a session-scoped interaction | NSObject, WCSessionDelegate |
WNonUIExtHandler |
Handles callbacks or feature events | PKIssuerProvisioningExtensionHandler |
WatchConnectivitySession |
Owns a session-scoped interaction | NSObject, WCSessionDelegate |
WNonUIExtHandler |
Handles callbacks or feature events | PKIssuerProvisioningExtensionHandler |
WUIExtHandler |
Handles callbacks or feature events | UIViewController, PKIssuerProvisioningExtensionAuthorizationProviding |
ProvisioningCredential |
Represents a feature value or composable behavior | Equatable, Codable, Hashable |
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 |
|---|---|---|---|
passCredentialsData (ImplementingWalletExtensionsSampleAppTests/TestModels.swift:67) |
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. |
getPaymentPassEntry (ImplementingWalletExtensionsSampleAppTests/WNonUIExtHandler.swift:231) |
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. |
getEntryArt (ImplementingWalletExtensionsSampleAppTests/WNonUIExtHandler.swift:270) |
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. |
getPaymentPassEntry (WNonUIExt/WNonUIExtHandler.swift:223) |
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
ImplementingWalletExtensionsSampleAppTests/TestModels.swift:67 — representative boundary
class MockUserDefaults: UserDefaults {
private var passCredentialsData: [String: ProvisioningCredential] = [:]
// ...
}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 | ImplementingWalletExtensionsSampleApp |
The source’s App suffix makes this role explicit. |
| Handles callbacks or feature events | WNonUIExtHandler, WUIExtHandler |
The source’s Handler suffix makes this role explicit. |
| Owns a session-scoped interaction | MockWatchConnectivitySession, WatchConnectivitySession |
The source’s Session suffix makes this role explicit. |
| User-interface presentation and input forwarding | LoginView, WUIExtView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Delegate or data-source callbacks | ImplementingWalletExtensionsSampleAppTests/WatchConnectivitySession.swift:13 |
Callback protocols invert event delivery back into the sample’s owner. |
Naming conventions
- Types: App: ImplementingWalletExtensionsSampleApp; Handler: WNonUIExtHandler, WUIExtHandler; Session: MockWatchConnectivitySession, WatchConnectivitySession; View: LoginView, WUIExtView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
handleLogin,handleBiometricLogin,requestPaymentPassData,data,bool,addPassCredentialJson,passes,isEqual. - Files:
ImplementingWalletExtensionsSampleApp/ImplementingWalletExtensionsSampleApp.swift,ImplementingWalletExtensionsSampleApp/LoginView.swift,WUIExt/WUIExtView.swift,WNonUIExt/Models/WatchConnectivitySession.swift,ImplementingWalletExtensionsSampleAppTests/WNonUIExtHandler.swift,ImplementingWalletExtensionsSampleAppTests/WatchConnectivitySession.swift.
Architecture takeaways
ImplementingWalletExtensionsSampleAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches PassKit, SwiftUI, WatchConnectivity, UIKit 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 |
|---|---|
ImplementingWalletExtensionsSampleApp/ImplementingWalletExtensionsSampleApp.swift |
Cited implementation, ImplementingWalletExtensionsSampleApp, SwiftUI |
ImplementingWalletExtensionsSampleApp/LoginView.swift |
Cited implementation, SwiftUI state property wrapper, LoginView |
ImplementingWalletExtensionsSampleAppTests/TestModels.swift |
Cited implementation, PassKit, os, ProvisioningCredential, PassResource, EncryptedPassDataResponse, MockUserDefaults, MockPKPassLibrary, MockPKPass, MockPKSecureElementPass, MockWatchConnectivitySession |
ImplementingWalletExtensionsSampleAppTests/WNonUIExtHandler.swift |
Cited implementation, WNonUIExtHandler |
WNonUIExt/WNonUIExtHandler.swift |
Cited implementation, WNonUIExtHandler |
ImplementingWalletExtensionsSampleAppTests/WatchConnectivitySession.swift |
Cited implementation, WatchConnectivity, WatchConnectivitySession |
WNonUIExt/Models/AppGroupManager.swift |
Foundation, Feature implementation |
WUIExt/WUIExtHandler.swift |
UIKit, WUIExtHandler |
WUIExt/WUIExtView.swift |
WUIExtView |
WNonUIExt/Models/WatchConnectivitySession.swift |
WatchConnectivitySession |
WNonUIExt/Models/MockClasses.swift |
ProvisioningCredential, EncryptedPassDataResponse, PassResource |
ImplementingWalletExtensionsSampleAppTests/WNonUIExtHandlerTests.swift |
WNonUIExtHandlerTests |