A next-generation, modular iOS/iPadOS/macOS/watchOS application for solving Rubik's Cubes with camera scanning and a stunning glassmorphic interface.
- Universal App: Runs seamlessly on iPhone, iPad, Mac, and Apple Watch
- Modular Architecture: Clean Swift Package modules (CubeCore, CubeUI, CubeScanner, CubeAR)
- Swift 6 Ready: Modern concurrency with async/await and Sendable conformance
- Glassmorphism Design: Beautiful Mac-style UI with glass effects
- Live Camera View: Real-time cube scanning with AVFoundation
- 3Γ3 Grid Overlay: Visual guide for accurate face scanning
- Color Detection: Vision framework-powered sticker recognition
- Confidence Scoring: Automatic quality assessment
- Manual Correction: Fix low-confidence stickers with intuitive UI
- 6-Face Scanning: Complete cube state capture
- Enhanced Solver: Two-phase algorithm with async/await support
- Physical Validation: Parity and orientation checks
- Move Optimization: Efficient solution generation
- Standard Notation: R, U', F2, etc.
- Step-by-Step Solutions: Interactive playback with controls
- Modern Navigation: SwiftUI NavigationStack
- Home Dashboard: Recent solves and statistics
- Solve History: Track all your solves with persistence
- Privacy Controls: Opt-in analytics (disabled by default)
- Settings: Comprehensive privacy and data management
- watchOS Ready: Architecture supports Watch companion (coming soon)
- Privacy First: All analytics opt-in only
- Local Storage: UserDefaults-based persistence
- Data Control: Clear history anytime
- GDPR Compliant: Respect for user privacy
- VoiceOver: Full screen reader support
- Accessibility Labels: All UI elements properly labeled
- Dynamic Type: Text scaling support
- High Contrast: Glassmorphic design works in all modes
- 58+ Unit Tests: 100% pass rate
- Modular Tests: Separate test suites for each module
- CI/CD: GitHub Actions integration
- Code Quality: SwiftLint enforcement
- Xcode: 26.0 or later (matches CI environment)
- iOS/iPadOS: 26.0 or later
- macOS: 26.0 or later
- Swift: 6.2 or later
- SwiftLint: For code quality checks (install via
brew install swiftlint)
- Clone the repository:
git clone https://github.com/markcoleman/CubeSolver.git
cd CubeSolver- Resolve dependencies and build:
swift package resolve
swift build- Run tests:
swift test --enable-code-coverage --parallel- Open in Xcode:
open CubeSolver.xcodeprojImportant: To ensure your local builds match CI builds, please follow the comprehensive setup guide:
π Local Development Environment Setup Guide
This guide covers:
- Matching Xcode and Swift versions with CI
- Resolving "works in CI, fails locally" issues
- Pre-commit validation scripts
- Build settings alignment
- Troubleshooting common problems
Quick validation: Run the pre-commit check script to verify your environment matches CI:
./scripts/pre-commit-check.shCubeSolver follows a modular Swift Package architecture with clean separation of concerns:
Core business logic and models (platform-independent)
- RubiksCube: 3D cube representation
- CubeState: 54-sticker state management
- EnhancedCubeSolver: Two-phase async solving algorithm
- CubeValidator: Physical legality validation
- Move/Turn/Amount: Standard notation types
- Sendable conformance: Swift 6 concurrency support
SwiftUI views and view models
- HomeView: Modern navigation hub
- CubeViewModel: Main view model with async solving
- CubeCamView: Camera-based auto-scan with video
- ManualPhotoCaptureView: Manual single-shot camera mode
- ManualInputView: Manual cube input
- SolutionPlaybackView: Step-by-step playback
- SolveHistoryManager: Persistence layer
- PrivacySettings: Privacy controls
- AnalyticsTracker: Opt-in analytics
Vision and Core ML integration (iOS only)
- CubeScanner: Camera-based cube detection
- Sticker Detection: Vision framework integration
- Color Classification: Core ML color recognition
- Confidence Scoring: Quality assessment
ARKit and RealityKit integration (iOS only)
- CubeARView: AR cube visualization
- Virtual Cube: 3D animated cube model
- MVVM: Clear separation of UI and logic
- Async/Await: Modern Swift concurrency
- ObservableObject: Reactive state management
- Modular Design: Clean dependencies
- Protocol-Oriented: Flexible abstractions
This repository now includes an additive scan pipeline and guided solve flow with DI-friendly boundaries.
CubeCore:FaceId,CubeFaceGrid,CubeStateAssemblerKociembaCodec,MoveNotationCodecCubeStateValidatorwith structuredValidationErrorCubeSolvingprotocol +KociembaCompatibleCubeSolver
CubeScanner:CameraFrameSource,FaceQuadDetecting,StickerColorClassifyingDefaultFaceScanner,FaceWarpSampler,HSVStickerClassifierVisionFaceQuadDetectorandCameraSessionFrameSourceadaptersSimulatedFaceScannerfor tests and demos
CubeUI:CubeScanSolveFlowViewModelScanWizardView,FaceConfirmView,CubeManualEditView,SolveStepsViewSolveModeView,SolveModeViewModel,SolveModeEngine
SolveModeView provides guided move-by-move solving with:
- single-step controls (
Back,Next,Play/Pause, speed, scrub slider) - deterministic state progression from
initialState + moves - primary 3D visualization (
CubeRenderer3DView) plus 2D fallback (CubeRenderer2DView) - human-readable move instructions and progress tracking
Orientation assumptions:
- Scan Wizard uses fixed orientation from capture order:
U, R, F, D, L, B. - In this flow,
Frontmaps to scannedF,Upmaps to scannedU. - When orientation is not guaranteed (for example manual input), enable
requireOrientationConfirmationinSolveModeViewto show an Orientation Lock confirmation step before playback.
Solve Mode rendering and animation are injected via protocols:
CubeRenderer:setState,highlight(move:),clearHighlight()CubeMoveAnimator: move animation contract with completion callback
To add a renderer:
- Implement
CubeRendererfor your view-backed renderer. - Provide a
CubeMoveAnimatorimplementation (or reuseTimedCubeMoveAnimator). - Inject both into
SolveModeViewModelfor headless-testable behavior.
Use dependency injection to choose live camera or simulated inputs.
import CubeCore
import CubeScanner
import CubeUI
let scanner = SimulatedFaceScanner(scriptedFaces: [
.up: ScannedFaceData(id: .up, grid: CubeFaceGrid(repeating: .white), confidence: 1),
.right: ScannedFaceData(id: .right, grid: CubeFaceGrid(repeating: .blue), confidence: 1),
.front: ScannedFaceData(id: .front, grid: CubeFaceGrid(repeating: .red), confidence: 1),
.down: ScannedFaceData(id: .down, grid: CubeFaceGrid(repeating: .yellow), confidence: 1),
.left: ScannedFaceData(id: .left, grid: CubeFaceGrid(repeating: .green), confidence: 1),
.back: ScannedFaceData(id: .back, grid: CubeFaceGrid(repeating: .orange), confidence: 1)
])
let vm = CubeScanSolveFlowViewModel(scanner: scanner)
let view = ScanWizardView(viewModel: vm)Run all tests:
swift test --parallelRun scanner-flow focused tests:
swift test --filter ScanSolvePipelineTests
swift test --filter ScanSolveFlowIntegrationTestsRun Solve Mode focused tests:
swift test --filter CubeMoveTests
swift test --filter CubeReducerTests
swift test --filter SolveModeEngineTests
swift test --filter MoveInstructionFormatterTests
swift test --filter SolveModeViewModelTests
swift test --filter SolveModeRenderingTestsKociembaCompatibleCubeSolvercurrently delegates to the built-in search solver (clean swap point for a true two-phase backend).DefaultFaceScannerdepends on provided frame source quality; production camera UX tuning is still needed for low light and motion blur.- Perspective handling uses bilinear face interpolation; a full homography/OpenCV warp can further improve edge cases.
- Add adaptive per-device color calibration from center stickers over multiple frames.
- Replace bilinear warping with true homography and temporal smoothing.
- Plug in a dedicated Kociemba/two-phase backend behind
CubeSolving. - Add UI test automation for scan wizard and manual edit conflict flows.
The app features a modern glassmorphic design inspired by macOS Big Sur and later:
- Ultra-thin material backdrops
- Subtle transparency and blur effects
- Smooth animations and transitions
- Responsive to system appearance (light/dark mode)
Run the test suite:
swift testOr in Xcode: Cmd + U
The project includes comprehensive unit tests for:
- Data Structures: CubeState, Move notation, Face/Turn enums
- Validation: Basic and physical legality checks
- Cube Model: Face rotations and state management
- Solver Algorithm: Two-phase solving with move generation
- ViewModel Logic: State management and operations
- Move Application: Scramble generation and application
- Test Coverage: 56+ tests with 100% pass rate
UI tests with screenshot capture are available for:
- Main interface validation
- Scramble, solve, and reset workflows
- Manual cube input interface
- Accessibility features
- Comprehensive screenshot gallery
Run UI tests in Xcode: Cmd + U (select CubeSolverUITests scheme)
The project uses SwiftLint for code quality enforcement:
swiftlintConfiguration is in .swiftlint.yml
CubeSolver/
βββ CubeSolver/
β βββ Sources/
β β βββ CubeSolverApp.swift # App entry point
β β βββ ContentView.swift # Main UI
β β βββ CubeView.swift # Cube visualization
β β βββ CubeViewModel.swift # ViewModel
β β βββ ManualInputView.swift # Original manual input
β β βββ ValidatedManualInputView.swift # Enhanced input with validation
β β βββ SolutionPlaybackView.swift # Solution visualization
β β βββ RubiksCube.swift # 3D cube model
β β βββ CubeSolver.swift # Original solver
β β βββ EnhancedCubeSolver.swift # Two-phase solver
β β βββ CubeDataStructures.swift # Core data types
β β βββ CubeValidation.swift # Validation logic
β βββ Tests/
β β βββ CubeSolverTests.swift # Original tests
β β βββ CubeDataStructuresTests.swift # Data structure tests
β β βββ CubeValidationTests.swift # Validation tests
β β βββ EnhancedCubeSolverTests.swift # Solver tests
β βββ UITests/
β βββ CubeSolverUITests.swift # UI tests
βββ docs/ # Documentation
βββ .github/
β βββ workflows/ # CI/CD
β βββ copilot-instructions.md # Copilot config
βββ .swiftlint.yml # Linting config
βββ Package.swift # SPM manifest
- Language: Swift 6.2+
- Framework: SwiftUI
- Package Manager: Swift Package Manager
- Testing: XCTest
- CI/CD: GitHub Actions
- Documentation: GitHub Pages
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
See CONTRIBUTING.md for detailed contribution guidelines.
Our GitHub Actions workflows are optimized to prevent duplicate runs and comments:
- Automated PR checks with deduplication - no more duplicate comments
- Smart workflow triggers to reduce unnecessary builds
- Concurrency control to cancel outdated runs
- Conditional screenshot capture - add
screenshotslabel to trigger
See .github/WORKFLOWS.md for complete workflow documentation.
This repository includes specialized GitHub Copilot agents to assist with development:
- SwiftUI Expert - UI components, platform-specific features, glassmorphic design
- Algorithm Expert - Cube solving algorithms, data structures, performance
- Accessibility Expert - VoiceOver, Dynamic Type, WCAG compliance
- Testing Specialist - XCTest, code coverage, test quality
- Documentation Expert - API docs, guides, technical writing
- DevOps Expert - CI/CD, GitHub Actions, deployment
See .github/agents/README.md for details on using these agents.
Full documentation is available at https://markcoleman.github.io/CubeSolver
- Getting Started - Quick start and installation
- Manual Input Guide - How to input a real cube pattern
- Enhanced CubeCam Guide - Using camera scanning features
- Accessibility Guide - Accessibility features and VoiceOver support
- API Reference - Complete API documentation
- Local Development Setup - Environment setup guide
- Testing Guide - Unit and UI testing documentation
- UI Testing Guide - Comprehensive UI testing
- Screenshot Automation - Automated screenshot capture
- DevOps Guide - CI/CD pipelines and workflows
- DevOps Summary - Quick reference for CI/CD
- DevOps Quick Reference - Common DevOps commands
- Workflows Documentation - GitHub Actions workflows
- Branch Protection - Repository protection rules
- Manual cube input for real-life cubes
- Validated manual input with real-time feedback
- Comprehensive accessibility support
- UI testing with screenshot capture
- Automated screenshot capture for App Store and documentation
- SwiftLint code quality enforcement
- Two-phase solving algorithm
- Solution playback with interactive controls
- Cube validation with physical legality checks
- Standard move notation (R, U', F2, etc.)
- 56+ comprehensive unit tests
- Advanced solving algorithms (Kociemba's full implementation, CFOP)
- Enhanced 3D cube visualization with SceneKit/RealityKit
- Smooth solution animation playback
- Statistics and solve time tracking
- Camera-based cube scanning with Vision/CoreML (AR)
- Multi-language support
- Optimal move count optimization
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the Rubik's Cube solving community
- Built with β€οΈ using SwiftUI
- Glassmorphism design inspired by macOS
Made with β€οΈ by the CubeSolver team
