Skip to content

Latest commit

 

History

History
93 lines (72 loc) · 3.25 KB

File metadata and controls

93 lines (72 loc) · 3.25 KB

Hackers App

Architecture Layers

  • Domain (Domain/): Business logic, models, use case protocols

    • Models: Post, Comment, User, TextSize
    • Use Cases: PostUseCase, CommentUseCase, SettingsUseCase, VoteUseCase
    • VotingStateProvider protocol and implementation
  • Data (Data/): Repository implementations, API interactions

    • Implements Domain protocols (PostRepository → PostUseCase)
    • Protocol-based UserDefaults for testability
  • Features (Features/): UI modules with MVVM pattern

    • Separate Swift Package per feature (Feed, Comments, Settings, Onboarding)
    • ViewModels: ObservableObject with @Published properties
    • SwiftUI views with @EnvironmentObject navigation
  • Shared (Shared/): DependencyContainer (singleton), navigation, common utilities

  • DesignSystem (DesignSystem/): Reusable UI components and styling

  • Networking (Networking/): NetworkManagerProtocol for API calls

Development Standards

Swift Configuration

  • iOS 26+ target, Swift 6.2
  • Swift concurrency (async/await)
  • @MainActor for UI code
  • Sendable conformance for thread safety

MVVM & Dependency Injection

  • ViewModels inject dependencies via protocols
  • DependencyContainer.shared provides all dependencies
  • Combine for reactive bindings
  • @StateObject for view-owned ViewModels
  • @EnvironmentObject for navigation/session state

Testing

  • Swift Testing framework (import Testing)
  • @Suite and @Test attributes
  • Test ViewModels, not Views
  • Mock dependencies with protocols

Build & Test Commands

Important: Working Directory

Always run xcodebuild from the project directory

Build Commands

# Build the app
xcodebuild -project Hackers.xcodeproj -scheme Hackers -destination 'platform=iOS Simulator,name=iPhone 17 Pro' build

# Clean and build
xcodebuild clean build -project Hackers.xcodeproj -scheme Hackers -destination 'platform=iOS Simulator,name=iPhone 17 Pro'

# Quick build status check
xcodebuild build -project Hackers.xcodeproj -scheme Hackers -destination 'platform=iOS Simulator,name=iPhone 17 Pro' 2>&1 | grep "BUILD"

Test Commands

# Run all tests
./run_tests.sh

# Run tests for specific module
./run_tests.sh Domain
./run_tests.sh Feed
./run_tests.sh Networking

Test Structure Notes

  • Tests are in Swift Package modules: Domain/Tests/, Data/Tests/, Features/*/Tests/
  • Each module has its own test target: DomainTests, DesignSystemTests, DataTests, etc.
  • Tests use Swift Testing framework with @Suite and @Test attributes
  • Do NOT use swift test - it runs on macOS and fails with iOS-only APIs
  • Tests must be run through Xcode with iOS Simulator destination

Known Configuration

  • Main Hackers.xcscheme properly configured with code coverage enabled
  • Individual module schemes auto-generated by Swift Package Manager
  • All tests compatible with iOS 26+ and Swift 6.2

Critical Guidelines

  • Do what has been asked; nothing more, nothing less
  • NEVER create files unless absolutely necessary
  • ALWAYS prefer editing existing files
  • NEVER proactively create documentation files
  • Never use git add . - add specific relevant changes only
  • Commit messages should be concise and descriptive
  • Never amend existing commits; always create a new commit for additional changes