Sample CodevisionOSReviewed 2026-07-21View on Apple Developer

Swift Splash

At a glance

Item Summary
Purpose Use RealityKit to create an interactive ride in visionOS.
App architecture A Swift sample with the source-visible chain SwiftSplashAppContentViewSoundEffectPlayerRealityKit / SwiftSplashTrackPieces APIs.
Main patterns Actor isolation
Project style 37 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: @MainActor, Task, await suspension point, Sendable or @Sendable, actor; none alone proves a background thread.
State/event model Source-visible mechanisms: @Observable, SwiftUI state property wrapper.
Key frameworks/packages RealityKit, Foundation, SwiftSplashTrackPieces, SwiftUI, os; these are source dependencies, not architecture labels.

Project structure

Source bundle/
├── SwiftSplash/
│   ├── SwiftSplashApp.swift
│   ├── Views/
│   │   ├── PieceShelfView.swift
│   │   ├── TrackBuildingView.swift
│   │   ├── ContentView.swift
│   │   ├── EditTrackPieceView.swift
│   │   ├── PieceShelfTrackButtonsView.swift
│   │   └── PlaceStartPieceView.swift
│   └── Data & State/
│       └── AppState.swift
└── Packages/
    └── SwiftSplashTrackPieces/
        └── Sources/
            └── SwiftSplashTrackPieces/
                ├── Components/
                │   ├── MarkerComponents.swift
                │   ├── ConnectableStateComponent.swift
                │   └── CustomBillboardComponent.swift
                └── Systems/
                    └── CustomBillboardSystem.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 3 project/configuration file(s) and 39 source declaration(s).

Overall architecture

Reference code

SwiftSplash/SwiftSplashApp.swift:12 — architecture anchor

@main
@MainActor
struct SwiftSplash: App {
    @Environment(\.openImmersiveSpace) private var openImmersiveSpace
    // ...
}

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

Ownership and state

Ownership evidence

SwiftSplash/SwiftSplashApp.swift:19 — stored dependency or nearest verified ownership anchor

@main
@MainActor
struct SwiftSplash: App {
    // ...
    @State private var appState = AppState()
    // ...
}
Owner Object or state Relationship Mutation authority
SwiftSplash AppState (appState) owns wrapper-managed state Owning lexical scope
SwiftSplash ImmersionStyle (immersionStyle) owns wrapper-managed state Owning lexical scope
RideAnimationComponent Double (timecodeWhenNotPlaying) owns value state App/module collaborators
RideWaterComponent Float (fillLevel) 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.

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
Main isolation @MainActor The cited annotation marks its attached declaration or closure as main-actor isolated. Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/Connectable.swift:13
Task creation Task The source creates an unstructured task; surrounding context determines inherited actor isolation. Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Systems/CustomBillboardSystem.swift:30
Suspension boundary await suspension point The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Systems/CustomBillboardSystem.swift:32
Transfer contract Sendable or @Sendable The source declares a sendability boundary; this alone does not synchronize mutable state. SwiftSplash/Data & State/AppPhase.swift:11
Actor isolation actor The cited type is actor-isolated; this does not select a background thread. SwiftSplash/Data & State/AppState+PieceLoading.swift:16

@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

Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/Connectable.swift:13 — representative execution boundary

@MainActor
public struct ConnectableComponent: Component, Codable {
    public init() {}
}

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 @Observable Observation macro publishes source-visible changes. SwiftSplash/Data & State/AppState.swift:38
State propagation SwiftUI state property wrapper A SwiftUI property wrapper supplies or observes UI state. SwiftSplash/SwiftSplashApp.swift:15
Source import RealityKit The cited file imports this module; runtime use and architectural role are not inferred. Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/Connectable.swift:9
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/Connectable.swift:8
Source import SwiftSplashTrackPieces The cited file imports this module; runtime use and architectural role are not inferred. SwiftSplash/Data & State/AppState+Phases.swift:12
Source import SwiftUI The cited file imports this module; runtime use and architectural role are not inferred. Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/ConnectableStateComponent.swift:12
Source import os The cited file imports this module; runtime use and architectural role are not inferred. SwiftSplash/Data & State/AppPhase.swift:8
Source import Combine The cited file imports this module; runtime use and architectural role are not inferred. Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/ConnectableStateComponent.swift:10

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

Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/MarkerComponents.swift:13 — representative type boundary

public struct PlaceStartPieceUIMarkerComponent: Component, Codable {
}
Type Responsibility Depends on or conforms to
PlaceStartPieceUIMarkerComponent Stores entity-component data or behavior Component, Codable
EditUILocationMarkerComponent Stores entity-component data or behavior Component, Codable
RideAnimationComponent Stores entity-component data or behavior Component, Codable
IdleAnimationComponent Stores entity-component data or behavior Component, Codable
RideWaterComponent Stores entity-component data or behavior Component, Codable
GlowComponent Stores entity-component data or behavior Component, Codable
ConnectableStateComponent Stores entity-component data or behavior Component, CustomStringConvertible
CustomBillboardComponent Stores entity-component data or behavior Component, Codable
CustomBillboardSystem Runs entity-component-system update logic System
PieceShelfView 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
Connectable (Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/Connectable.swift:15) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
dragStart (Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/ConnectableStateComponent.swift:19) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
dragOffset (Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/ConnectableStateComponent.swift:20) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
lastMoved (Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/ConnectableStateComponent.swift:21) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.

Reference code

Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/Connectable.swift:15 — representative boundary

    public init() {}

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
Stores entity-component data or behavior ConnectableComponent, ConnectableStateComponent, CustomBillboardComponent, EditUILocationMarkerComponent The source’s Component suffix makes this role explicit.
Owns media or timeline playback SoundEffectPlayer The source’s Player suffix makes this role explicit.
Runs entity-component-system update logic CustomBillboardSystem The source’s System suffix makes this role explicit.
User-interface presentation and input forwarding ContentView, EditTrackPieceView, PieceShelfTrackButtonsView, PieceShelfView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
Actor isolation SwiftSplash/Data & State/AppState+PieceLoading.swift:16 A declared actor creates an explicit isolation boundary; its executor is not described as a background thread.

Naming conventions

  • Types: Component: ConnectableComponent, ConnectableStateComponent, CustomBillboardComponent, EditUILocationMarkerComponent, GlowComponent; Player: SoundEffectPlayer; System: CustomBillboardSystem; View: ContentView, EditTrackPieceView, PieceShelfTrackButtonsView, PieceShelfView, PlaceStartPieceView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: setUpSession, update, setAnimateIn, makeBody.
  • Files: Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/ConnectableStateComponent.swift, Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/CustomBillboardComponent.swift, Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Systems/CustomBillboardSystem.swift, SwiftSplash/Views/PieceShelfView.swift, SwiftSplash/Views/TrackBuildingView.swift, SwiftSplash/Data & State/AppState.swift.

Architecture takeaways

  • SwiftSplashApp is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches RealityKit, SwiftSplashTrackPieces, SwiftUI, ARKit 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
SwiftSplash/SwiftSplashApp.swift Cited implementation, SwiftUI state property wrapper, SwiftSplash
Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/MarkerComponents.swift PlaceStartPieceUIMarkerComponent, EditUILocationMarkerComponent, RideAnimationComponent, IdleAnimationComponent, RideWaterComponent, GlowComponent
Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/Connectable.swift Cited implementation, @MainActor, RealityKit, Foundation, ConnectableComponent
Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/ConnectableStateComponent.swift Cited implementation, SwiftUI, Combine, ConnectableStateComponent
SwiftSplash/Data & State/AppState+PieceLoading.swift EntityContainer, actor, LoadResult
Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Systems/CustomBillboardSystem.swift Task, await suspension point, CustomBillboardSystem
SwiftSplash/Data & State/AppPhase.swift Sendable or @Sendable, os, AppPhase
SwiftSplash/Data & State/AppState.swift @Observable, TilePieceKey, ConnectionPointType, AppState, RideDestination
SwiftSplash/Data & State/AppState+Phases.swift SwiftSplashTrackPieces, Feature implementation
Packages/SwiftSplashTrackPieces/Sources/SwiftSplashTrackPieces/Components/CustomBillboardComponent.swift CustomBillboardComponent
SwiftSplash/Views/PieceShelfView.swift PieceShelfView, TranslucentGroupBox
SwiftSplash/Views/TrackBuildingView.swift TrackBuildingView, AttachmentIDs
SwiftSplash/Views/ContentView.swift ContentView
SwiftSplash/Views/EditTrackPieceView.swift EditTrackPieceView
SwiftSplash/Views/PieceShelfTrackButtonsView.swift PieceShelfTrackButtonsView
SwiftSplash/Views/PlaceStartPieceView.swift PlaceStartPieceView