Building a guessing game for visionOS
At a glance
| Item | Summary |
|---|---|
| Purpose | Create a team-based guessing game for visionOS using Group Activities. |
| App architecture | A Swift sample with the source-visible chain GuessTogetherApp → SessionController → PhraseManager → GroupActivities APIs. |
| Main patterns | View-controller organization, Central store, Actor-isolated state |
| Project style | 25 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
└── GuessTogether/
├── GuessTogetherApp.swift
├── Models/
│ ├── GameModel.swift
│ ├── PlayerModel.swift
│ └── AppModel.swift
├── ImmersiveSpace/
│ ├── PhraseDeckView.swift
│ ├── PhraseDeckPodiumView.swift
│ └── SeatScoresView.swift
├── Utilities/
│ └── PhraseManager.swift
├── WindowViews/
│ ├── GameScoreBoardView.swift
│ ├── TeamSelectionView.swift
│ └── WelcomeView.swift
└── GroupActivity/
└── SessionController.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 37 source declaration(s).
Overall architecture
flowchart LR
N1["GuessTogetherApp"]
N2["SessionController"]
N3["PhraseManager"]
N4["GroupActivities APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
Reference code
GuessTogether/GuessTogetherApp.swift:10 — architecture anchor
@main
struct GuessTogetherApp: App {
// ...
}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 Group Activities.
Ownership and state
classDiagram
GuessTogetherApp *-- AppModel : appModel
GameModel o-- ActivityStage : stage
GameModel o-- Excludedcategories : excludedCategories
GameModel *-- Array : turnHistory
Ownership evidence
GuessTogether/GuessTogetherApp.swift:12 — stored dependency or nearest verified ownership anchor
@State var appModel = AppModel()| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
GuessTogetherApp |
AppModel (appModel) |
owns wrapper-managed state | App/module collaborators |
GameModel |
ActivityStage (stage) |
stores or receives | App/module collaborators |
GameModel |
Excludedcategories (excludedCategories) |
stores or receives | App/module collaborators |
GameModel |
Array (turnHistory) |
owns value 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
GuessTogether/GuessTogetherApp.swift:11 — representative type boundary
struct GuessTogetherApp: App {
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
GuessTogetherApp |
Application entry and top-level composition | App |
GameModel |
Feature data or observable state | Codable, Hashable, Sendable |
PhraseDeckView |
User-interface presentation and input forwarding | View |
PhraseCardView |
User-interface presentation and input forwarding | View |
PlayerModel |
Feature data or observable state | Codable, Hashable, Sendable, Identifiable |
AppModel |
Feature data or observable state | Concrete collaborators/imported frameworks |
PhraseManager |
Long-lived feature or framework coordination | Sendable |
ScoreBoardView |
User-interface presentation and input forwarding | View |
TeamStatusView |
User-interface presentation and input forwarding | View |
TeamSelectionView |
User-interface presentation and input forwarding | View |
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 |
|---|---|---|---|
observeRemoteGameModelUpdates (GuessTogether/GroupActivity/SessionController+RemoteParticipantSynchronization.swift:46) |
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. |
observeRemotePlayerModelUpdates (GuessTogether/GroupActivity/SessionController+RemoteParticipantSynchronization.swift:76) |
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. |
observeActiveRemoteParticipants (GuessTogether/GroupActivity/SessionController+RemoteParticipantSynchronization.swift:84) |
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. |
phrases (GuessTogether/Utilities/PhraseManager.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. |
Reference code
GuessTogether/GroupActivity/SessionController+RemoteParticipantSynchronization.swift:46 — representative boundary
private func observeRemoteGameModelUpdates() {
// ...
}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 | GuessTogetherApp |
The source’s App suffix makes this role explicit. |
| View lifecycle, callbacks, and feature coordination | SessionController |
The source’s Controller suffix makes this role explicit. |
| Long-lived feature or framework coordination | PhraseManager |
The source’s Manager suffix makes this role explicit. |
| Feature data or observable state | AppModel, GameModel, PlayerModel |
The source’s Model suffix makes this role explicit. |
| Centralized state or persistence access | GameSyncStore |
The source’s Store suffix makes this role explicit. |
| User-interface presentation and input forwarding | ActivitySharingView, CategorySelectionView, MainView, PhraseCardView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| View-controller organization | GuessTogether/GroupActivity/SessionController.swift:12 |
A controller is the verified coordination boundary; this is MVC-style only where a separate model is present. |
| Central store | GuessTogether/GroupActivity/SessionController+RemoteParticipantSynchronization.swift:130 |
A store-named type centralizes feature state or persistence. |
| Actor-isolated state | GuessTogether/GroupActivity/SessionController.swift:11 |
Actor annotations make the concurrency ownership boundary explicit. |
Naming conventions
- Types: App: GuessTogetherApp; Controller: SessionController; Manager: PhraseManager; Model: AppModel, GameModel, PlayerModel; Store: GameSyncStore; View: ActivitySharingView, CategorySelectionView, MainView, PhraseCardView, PhraseDeckPodiumView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
randomPhrase,teamHasPlayers,playersOnTeam. - Files:
GuessTogether/GuessTogetherApp.swift,GuessTogether/Models/GameModel.swift,GuessTogether/ImmersiveSpace/PhraseDeckView.swift,GuessTogether/Models/PlayerModel.swift,GuessTogether/Models/AppModel.swift,GuessTogether/Utilities/PhraseManager.swift.
Architecture takeaways
GuessTogetherAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches SwiftUI, GroupActivities, Spatial, CoreTransferable 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 |
|---|---|
GuessTogether/GuessTogetherApp.swift |
GuessTogetherApp |
GuessTogether/Models/GameModel.swift |
GameModel, GameStage, ActivityStage |
GuessTogether/ImmersiveSpace/PhraseDeckView.swift |
PhraseDeckView, PhraseDeckButton, Kind, PhraseCardView |
GuessTogether/Models/PlayerModel.swift |
PlayerModel, Team |
GuessTogether/Models/AppModel.swift |
AppModel |
GuessTogether/Utilities/PhraseManager.swift |
PhraseManager, Phrase |
GuessTogether/WindowViews/GameScoreBoardView.swift |
ScoreBoardView, TeamStatusView |
GuessTogether/WindowViews/TeamSelectionView.swift |
TeamSelectionView, TeamList |
GuessTogether/WindowViews/WelcomeView.swift |
WelcomeView, WelcomeBanner |
GuessTogether/GroupActivity/SessionController.swift |
SessionController |