How suhang12332/swift-craft-launcher works
1. Product shape and runtime
- This is a native macOS 14+ app written in Swift 5.5+ with SwiftUI as the primary UI framework and Combine for reactive state.
- The app is organized as a single Xcode project with feature-oriented source folders rather than separate packages.
2. Top-level application shell
- SwiftCraftLauncherApp.swift is the app entry point.
- The UI is centered around a main window and supporting sheets/windows, with custom window management helpers in CommonFeature/Utilities.
- MainFeature owns the launcher shell: sidebar, content/detail panes, toolbar, menu bar extra content, and navigation/presentation behavior.
3. Feature-boundary architecture
- The codebase is split into distinct feature areas:
- MainFeature for shell/navigation
- GameFeature for game instance management and launching
- ResourceFeature for browsing/installing remote resources
- PlayerFeature for accounts, profiles, skins, and friends/presence
- ModPackFeature for importing/exporting/installing modpacks
- CommonFeature for shared app-wide infrastructure
- This separation is important: each feature has its own models, services, view models, views, and utility code.
4. Presentation layer
- The UI is largely MVVM-style: SwiftUI views bind to feature-specific view models.
- CommonFeature/Views contains reusable building blocks like sheets, sections, file tree views, settings views, and about/contributor screens.
- Feature views are specialized by domain: game detail, modpack import/export, resource browsing, player skins, AI chat, etc.
5. Core launcher shell flow
- The main screen is driven by SidebarViewModel, ContentToolbarViewModel, and related context-menu/action view models.
- MainFeature routes user actions into the current feature pane and presents sheets/dialogs through presentation utilities.
- The shell is responsible for coordinating selection state, toolbar actions, and game-related commands, but not for the underlying game logic itself.
6. Game management subsystem
- GameFeature is the core launcher engine for Minecraft instances.
- It covers game creation, validation, settings, Java runtime selection, save/world metadata, server address handling, local resource management, and launch orchestration.
- The launch path runs through GameLaunchUseCase, MinecraftLaunchCommandBuilder, and GameProcessManager, which together assemble and execute the Minecraft process.
7. Game data, persistence, and filesystem boundaries
- Game state is persisted through local databases and file-oriented managers:
- GameRepository, GameVersionDatabase, ModCacheDatabase, SQLiteDatabase
- file managers for Minecraft directories, common files, save info, and mod caches
- The architecture strongly depends on the local filesystem: instance directories, logs, assets, mods, worlds, screenshots, and Java runtimes are all treated as first-class local resources.
8. Remote resource discovery and installation
- ResourceFeature handles search, filtering, detail loading, and installation of external content such as mods, datapacks, shaders, and resource packs.
- It focuses on Modrinth-related browsing and compatibility views, with download/installation helpers and dependency resolution.
- The resource layer is separated from game launching so that remote project metadata and install logic do not leak into the shell layer.
9. Modpack import/export pipeline
- ModPackFeature is a separate workflow for ingesting and producing modpack artifacts.
- It includes index parsing/adapters for CurseForge and Modrinth, installers, archive/export builders, manifest parsers, and resource processors.
- The data flow here is: archive/index input → parser/adapter → normalized internal model → dependency/resource processing → local instance installation or exported package.
10. Player/account/identity subsystem
- PlayerFeature covers player profiles, account storage, skins, capes, and Microsoft/Yggdrasil-related identity handling.
- It persists credentials and user profiles locally, and also supports skin libraries and presence/friends integrations.
- This subsystem is the boundary between the launcher’s local identity store and external authentication/profile services.
11. Shared service and model layer
- CommonFeature hosts app-wide services and models used by multiple features:
- authentication services
- Modrinth/CurseForge/GitHub/IP-location services
- update checking via Sparkle
- cache, settings, language, notification, and announcement managers
- shared API client, logging, keychain, and path utilities
- This is the main cross-cutting boundary: features should depend on these shared services rather than duplicating networking, caching, or settings code.
12. External integrations
- The app talks to several external systems that materially shape the architecture:
- Microsoft auth and Yggdrasil for account login
- Modrinth and CurseForge for mods/modpacks
- GitHub for metadata and updates
- Sparkle for app update delivery
- Java runtime downloads and Minecraft version manifest sources
- These integrations are encapsulated behind services so the UI and feature view models consume normalized domain data.
13. Local state, caching, and security
- The app uses local caches and state managers to avoid repeated network/file work and to keep UI responsive.
- Sensitive data is handled through a KeychainManager, while other cached state is managed through app cache and feature-specific state stores.
- Download and progress coordination are also explicit subsystems, reflecting the app’s heavy use of asynchronous network and file transfer work.
14. Build, packaging, and distribution
- The repo includes GitHub Actions for building a DMG release and a small scripting tool under .github/scripts.
- archify.py and the workflow indicate release packaging/optimization for macOS distribution.
- The README also points to Homebrew Cask distribution, so the product is designed for both direct downloads and packaged installation.
15. What an architecture diagram should emphasize
- Draw the app as a SwiftUI shell around multiple domain features, with CommonFeature as the shared infrastructure layer.
- Show local filesystem / SQLite / Keychain as the primary persistence boundary.
- Show network services to Microsoft, Modrinth, CurseForge, GitHub, Sparkle, and IP/location endpoints as external dependencies.
- The main runtime flow is: user action in SwiftUI → feature view model → service/manager/use-case layer → local storage or remote API → updated state back to the UI.
Main entry points: AppServices.swift Shared Services · GameCreationViewModel.swift Game ViewModels · ModrinthDetailCoordinatorViewModel.swift Resource VM · MinecraftFileManager.swift File Managers
Components 20
App Shell
Top-level SwiftUI application shell and navigation
- Launcher App · Application entry point and lifecycle root
SwiftCraftLauncher/SwiftCraftLauncherApp.swift - Main View · Primary window shell with sidebar, content, and detail panes
SwiftCraftLauncher/MainFeature/Views/MainView.swift - Sidebar VM · Drives selection and shell navigation state
SwiftCraftLauncher/MainFeature/ViewModels/SidebarViewModel.swift - Toolbar VM · Coordinates toolbar content and shell actions
SwiftCraftLauncher/MainFeature/ViewModels/ContentToolbarViewModel.swift - Presentation · Window, sheet, and dialog presentation utilities
SwiftCraftLauncher/MainFeature/Utilities/MainViewPresentationModifier.swift
Common Feature
Shared infrastructure and cross-cutting services
- Shared Services · Shared services, API clients, logging, settings, caching, and integrations
SwiftCraftLauncher/CommonFeature/Utilities/AppServices.swift - Auth Services · Microsoft and Yggdrasil authentication plus profile parsing
SwiftCraftLauncher/CommonFeature/Services/MinecraftAuthService.swift - Remote APIs · Modrinth, CurseForge, GitHub, IP location, and update services
SwiftCraftLauncher/CommonFeature/Services/ModrinthService.swift - Local Core · Paths, keychain, downloads, and local app state helpers
SwiftCraftLauncher/CommonFeature/Utilities/AppPaths.swift
Game Feature
Minecraft instance management, launch, and local game state
- Launch Pipeline · Builds and executes the Minecraft launch command
SwiftCraftLauncher/GameFeature/UseCases/GameLaunchUseCase.swift - Game Storage · SQLite databases and repository layer for game state
SwiftCraftLauncher/GameFeature/Data/GameRepository.swift - File Managers · Instance directories, resources, saves, mods, and Java runtime file handling
SwiftCraftLauncher/GameFeature/Managers/MinecraftFileManager.swift - Process Runtime · Launch command building and Minecraft process management
SwiftCraftLauncher/GameFeature/Run/GameProcessManager.swift - Game ViewModels · Creation, settings, and local resource coordination
SwiftCraftLauncher/GameFeature/ViewModels/GameCreationViewModel.swift
Resource Feature
Remote resource discovery, filtering, and installation
- Resource VM · Search, filter, and detail coordination for remote resources
SwiftCraftLauncher/ResourceFeature/ViewModels/Modrinth/ModrinthDetailCoordinatorViewModel.swift - Resource Loader · Loads resource details and checks installation state
SwiftCraftLauncher/ResourceFeature/Utilities/ResourceDetailLoader.swift
Player Feature
Accounts, profiles, skins, and presence
- Player Storage · Account, profile, and skin stores
SwiftCraftLauncher/PlayerFeature/Data/PlayerDataManager.swift - Skin Service · Skin and cape handling plus player customization utilities
SwiftCraftLauncher/PlayerFeature/Services/PlayerSkinService.swift
ModPack Feature
Modpack import, processing, and export workflows
- Modpack Flow · Parses, adapts, installs, and exports modpack artifacts
SwiftCraftLauncher/ModPackFeature/Services/ModPackInstallCoordinator.swift - Archive IO · Archive parsing and CurseForge/Modrinth index adaptation
SwiftCraftLauncher/ModPackFeature/Services/ModPackIndexParser.swift
Connections 32
- Launcher App → Main View: hosts · App entry creates the main launcher shell
- Main View → Sidebar VM: binds · Shell UI binds to navigation state
- Main View → Toolbar VM: binds · Shell UI binds to toolbar actions
- Main View → Presentation: presents · Window and sheet orchestration for dialogs and secondary surfaces
- Sidebar VM → Game ViewModels: selects · Selection state routes into game-related panes
- Sidebar VM → Resource VM: selects · Selection state routes into resource browsing panes
- Sidebar VM → Player Storage: selects · Selection can surface player/account management
- Toolbar VM → Launch Pipeline: triggers · Toolbar actions initiate game launch and management flows
- Toolbar VM → Resource VM: filters · Toolbar controls resource browsing and filtering
- Shared Services → Auth Services: includes · Shared infrastructure provides auth services
- Shared Services → Remote APIs: includes · Shared infrastructure provides remote API integrations
- Shared Services → Local Core: includes · Shared infrastructure provides local app services and utilities
- Game ViewModels → Game Storage: reads/writes · Feature view models persist and query game state
- Game ViewModels → File Managers: manages · Game UI and forms coordinate filesystem-backed instance state
- Game ViewModels → Launch Pipeline: launches · Game feature delegates launch orchestration to the use case
- Launch Pipeline → Process Runtime: executes · Use case builds and runs the Minecraft process
- Launch Pipeline → File Managers: depends on · Launch orchestration needs local instance files and runtime assets
- Game Storage → Local Core: persists via · Game persistence depends on local filesystem and storage utilities
- File Managers → Local Core: uses · File managers rely on shared path, download, and cache helpers
- Resource VM → Resource Loader: loads · Search/detail view models fetch resource details and install state
- Resource VM → Remote APIs: queries · Resource browsing depends on remote marketplace APIs
- Resource Loader → File Managers: installs to · Remote resources are installed into game instance files
- Player Storage → Auth Services: backed by · Identity storage is paired with authentication services
- Skin Service → Player Storage: updates · Skin and profile actions update persisted player state
- Skin Service → Remote APIs: fetches · Skin/profile features may use external profile services
- Modpack Flow → Archive IO: parses · Modpack workflows start from archive and index adapters
- Modpack Flow → File Managers: installs to · Processed modpacks are installed into local instances
- Modpack Flow → Remote APIs: downloads · Modpack workflows resolve and download remote artifacts
- Shared Services → Game ViewModels: shared by · Game feature consumes shared managers and services
- Shared Services → Resource VM: shared by · Resource feature consumes shared managers and services
- Shared Services → Player Storage: shared by · Player feature consumes shared managers and services
- Shared Services → Modpack Flow: shared by · Modpack feature consumes shared managers and services