Complete native rewrite of the web-based SoliCards game as a SwiftUI multiplatform app targeting iOS 17+, iPadOS 17+, and macOS 14+. Three solitaire variants (Klondike, Spider, FreeCell) with full game rules, drag & drop, smart zoom layout, 6 themes, 4 difficulty levels, SwiftData persistence, VoiceOver accessibility, and 57 unit tests. Key features: - MVVM + Protocol-Oriented Strategy architecture - DragGesture with coordinate-space hit-testing (long press + drag) - Smart zoom: cards auto-size to fit screen based on deepest column - Landscape: 30% bigger cards with scrollable overflow (iOS) - macOS: 120pt card cap, 92% height buffer for window resizing - Auto-save, game resume, statistics tracking via SwiftData - Privacy manifest, app icon, String Catalog, zero dependencies Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2.4 KiB
2.4 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What This Project Is
SoliCards is a native SwiftUI solitaire card game for iOS 17+, iPadOS 17+, and macOS 14+. It was ported from a web-based JavaScript game (game-SoliCards/SoliCards.html) following the 7-phase workflow defined in PROMPT.md.
Build Commands
# Generate Xcode project (required after cloning or editing project.yml)
xcodegen generate
# Build for iOS Simulator
xcodebuild build -project SoliCards.xcodeproj -scheme SoliCards -destination 'platform=iOS Simulator,name=iPhone 16'
# Build for macOS
xcodebuild build -project SoliCards.xcodeproj -scheme SoliCards -destination 'platform=macOS' CODE_SIGN_IDENTITY=- CODE_SIGNING_REQUIRED=NO
# Run tests
xcodebuild test -project SoliCards.xcodeproj -scheme SoliCardsTests -destination 'platform=iOS Simulator,name=iPhone 16'
# Static analysis
xcodebuild analyze -project SoliCards.xcodeproj -scheme SoliCards -destination 'platform=iOS Simulator,name=iPhone 16'
Architecture
MVVM + Protocol-Oriented Strategy — see ARCHITECTURE.md for full details.
GameRulesprotocol with 3 conforming structs:KlondikeRules,SpiderRules,FreeCellRules@Observablemacro (notObservableObject) for property-level SwiftUI observation@MainActoron ViewModels and TimerService for Swift 6 concurrency safetyDragGesture+PreferenceKeyframe hit-testing for card drag & drop (notonDrag/onDrop)- SwiftData for persistence (
GameRecord,StatsRecord,PrefsRecord) - Zero external dependencies
Key Conventions
.xcodeprojis generated by xcodegen fromproject.yml— do not edit it by handArray.trailingSuffix(while:)extension replaces missing stdlibsuffix(while:)— used in rules engines for face-up card runs- Card images are loaded from the asset catalog via platform-conditional helpers (
UIImage/NSImage) inCardView - Sound playback is dispatched via
nonisolated func playSound()to avoid@MainActorisolation on the audio path
Test Suite
57 tests across 12 suites. All tests are in SoliCardsTests/ using Swift Testing (@Test, #expect).
Key test coverage areas:
GameEngine/— KlondikeRules, SpiderRules, FreeCellRules, MoveValidator, AutoCompleter, GameStateModels/— Card, Deck, Difficulty, GameVariant, Rank, Suit