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. |
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.
Class and protocol design
ImplementingWalletExtensionsSampleApp/ImplementingWalletExtensionsSampleApp.swift:11 — representative type boundary
struct ImplementingWalletExtensionsSampleApp: App {
var body: some Scene {
WindowGroup {
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
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 |
ImplementingWalletExtensionsSampleApp |
ImplementingWalletExtensionsSampleApp/LoginView.swift |
LoginView |
WUIExt/WUIExtView.swift |
WUIExtView |
ImplementingWalletExtensionsSampleAppTests/TestModels.swift |
ProvisioningCredential, PassResource, EncryptedPassDataResponse, MockUserDefaults, MockPKPassLibrary, MockPKPass, MockPKSecureElementPass, MockWatchConnectivitySession |
WNonUIExt/Models/WatchConnectivitySession.swift |
WatchConnectivitySession |
WNonUIExt/Models/AppGroupManager.swift |
Feature implementation |
WNonUIExt/Models/MockClasses.swift |
ProvisioningCredential, EncryptedPassDataResponse, PassResource |
ImplementingWalletExtensionsSampleAppTests/WNonUIExtHandler.swift |
WNonUIExtHandler |
ImplementingWalletExtensionsSampleAppTests/WatchConnectivitySession.swift |
WatchConnectivitySession |
WNonUIExt/WNonUIExtHandler.swift |
WNonUIExtHandler |