Emoji Rangers: Supporting Live Activities, interactivity, and animations
At a glance
| Item | Summary |
|---|---|
| Purpose | Offer Live Activities, controls, animate data updates, and add interactivity to widgets. |
| App architecture | A C/Objective-C header, Swift sample bundle with entry-bearing project variants Emoji Rangers, EmojiRangerWidgetExtension, EmojiRangersWatchApp, each leading to WidgetKit APIs. |
| Main patterns | Model-View-ViewModel, Publisher-backed observable state, Actor-isolated state |
| Project style | 24 scanned source file(s) across C/Objective-C header, Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
├── Emoji Rangers/
│ ├── EmojiRangersApp.swift
│ ├── Shared/
│ │ └── Views/
│ │ ├── AdventureLiveActivityView.swift
│ │ └── AvatarView.swift
│ ├── Game Status/
│ │ ├── AdventureView.swift
│ │ └── AdventureViewModel.swift
│ └── ContentView.swift
├── EmojiRangersWatchApp/
│ ├── EmojiRangersWatchApp.swift
│ └── ContentView.swift
├── EmojiRangerWidgetExtension/
│ ├── EmojiRangersWidgetBundle.swift
│ ├── EmojiRangersWidget.swift
│ └── LeaderboardWidget.swift
└── App Intent/
└── EmojiRangerSelection.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: C/Objective-C header, Swift.
- The verified tree contains 11 project/configuration file(s) and 44 source declaration(s).
Overall architecture
flowchart LR
Bundle["Sample bundle"]
V1["Emoji Rangers"]
V2["EmojiRangerWidgetExtension"]
V3["EmojiRangersWatchApp"]
Boundary["WidgetKit APIs"]
Bundle --> V1
V1 --> Boundary
Bundle --> V2
V2 --> Boundary
Bundle --> V3
V3 --> Boundary
Reference code
Emoji Rangers/EmojiRangersApp.swift:10 — architecture anchor
@main
struct EmojiRangersApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}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
classDiagram
AdventureLiveActivityContent o-- EmojiRanger : hero
AdventureLiveActivityContent *-- Bool : isStale
AdventureLiveActivityContent o-- ContentState : contentState
AdventureLiveActivityView o-- EmojiRanger : hero
Ownership evidence
Emoji Rangers/Shared/Views/AdventureLiveActivityView.swift:14 — stored dependency or nearest verified ownership anchor
struct AdventureLiveActivityContent: View {
let hero: EmojiRanger
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
AdventureLiveActivityContent |
EmojiRanger (hero) |
stores or receives | Initialized by the owner; the binding is immutable |
AdventureLiveActivityContent |
Bool (isStale) |
owns value state | Initialized by the owner; the binding is immutable |
AdventureLiveActivityContent |
ContentState (contentState) |
stores or receives | Initialized by the owner; the binding is immutable |
AdventureLiveActivityView |
EmojiRanger (hero) |
stores or receives | 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.
Class and protocol design
Emoji Rangers/EmojiRangersApp.swift:11 — representative type boundary
struct EmojiRangersApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
EmojiRangersApp |
Application entry and top-level composition | App |
EmojiRangersWatchAppApp |
Application entry and top-level composition | App |
AdventureLiveActivityView |
User-interface presentation and input forwarding | View |
LiveActivityAvatarView |
User-interface presentation and input forwarding | View |
EventDescriptionView |
User-interface presentation and input forwarding | View |
OneLineStatsView |
User-interface presentation and input forwarding | View |
TwoLineStatsView |
User-interface presentation and input forwarding | View |
AdventureView |
User-interface presentation and input forwarding | View |
AdventureViewModel |
UI-facing state and feature coordination | ObservableObject |
EmojiRangerOptionsProvider |
Supplies a capability or framework resource | DynamicOptionsProvider |
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 |
|---|---|---|---|
selection (Emoji Rangers/ContentView.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. |
navigationPath (Emoji Rangers/ContentView.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. |
currentActivity (Emoji Rangers/Game Status/AdventureView.swift:156) |
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. |
queue (Emoji Rangers/Shared/Mock API/ImageURLProtocol.swift:14) |
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. |
Reference code
Emoji Rangers/ContentView.swift:12 — representative boundary
struct ContentView: View {
// ...
@State private var selection: EmojiRanger?
// ...
}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 | EmojiRangersApp, EmojiRangersWatchAppApp |
The source’s App suffix makes this role explicit. |
| Supplies a capability or framework resource | AppIntentProvider, EmojiRangerOptionsProvider, LeaderboardProvider |
The source’s Provider suffix makes this role explicit. |
| User-interface presentation and input forwarding | AdventureLiveActivityView, AdventureView, AllCharactersView, AvatarView |
The source’s View suffix makes this role explicit. |
| UI-facing state and feature coordination | AdventureViewModel |
The source’s ViewModel suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Model-View-ViewModel | Emoji Rangers/Game Status/AdventureView.swift:117 |
Role-named view models keep UI-facing state or coordination outside view declarations. |
| Publisher-backed observable state | Emoji Rangers/Game Status/AdventureView.swift:153 |
Published properties notify observers while mutation remains with the state object. |
| Actor-isolated state | Emoji Rangers/Game Status/AdventureView.swift:116 |
Actor annotations make the concurrency ownership boundary explicit. |
Naming conventions
- Types: App: EmojiRangersApp, EmojiRangersWatchAppApp; Provider: AppIntentProvider, EmojiRangerOptionsProvider, LeaderboardProvider; View: AdventureLiveActivityView, AdventureView, AllCharactersView, AvatarView, ContentView; ViewModel: AdventureViewModel.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
loadAdventure,startAdventureButtonTapped,updateAdventureButtonTapped,endAdventureButtonTapped,endActivity,setup,observeActivity,updateAdventure. - Files:
Emoji Rangers/EmojiRangersApp.swift,Emoji Rangers/Shared/Views/AdventureLiveActivityView.swift,EmojiRangerWidgetExtension/EmojiRangersWidgetBundle.swift,Emoji Rangers/Game Status/AdventureView.swift,App Intent/EmojiRangerSelection.swift,Emoji Rangers/ContentView.swift.
Architecture takeaways
EmojiRangersAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches SwiftUI, WidgetKit, ActivityKit, AppIntents 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 |
|---|---|
Emoji Rangers/EmojiRangersApp.swift |
EmojiRangersApp |
EmojiRangersWatchApp/EmojiRangersWatchApp.swift |
EmojiRangersWatchAppApp |
Emoji Rangers/Shared/Views/AdventureLiveActivityView.swift |
AdventureLiveActivityContent, AdventureLiveActivityView, LiveActivityAvatarView, HealthBar, EventDescriptionView, OneLineStatsView, TwoLineStatsView |
EmojiRangerWidgetExtension/EmojiRangersWidgetBundle.swift |
EmojiRangersWidgetBundle |
Emoji Rangers/Game Status/AdventureView.swift |
AdventureView, AdventureViewModel, ActivityViewState |
Emoji Rangers/Game Status/AdventureViewModel.swift |
Feature implementation |
App Intent/EmojiRangerSelection.swift |
EmojiRangerSelection, EmojiRangerOptionsProvider, RangerQuery |
Emoji Rangers/ContentView.swift |
ContentView, TableRow |
Emoji Rangers/Shared/Views/AvatarView.swift |
Avatar, AvatarView |
EmojiRangerWidgetExtension/EmojiRangersWidget.swift |
EmojiRangerControl, SimpleEntry, PlaceholderView, EmojiRangerWidgetEntryView, EmojiRangerWidget |