|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build, Test, and Development Commands |
| 6 | + |
| 7 | +### Building the Project |
| 8 | +```bash |
| 9 | +# Build for Debug |
| 10 | +xcodebuild -project NativeAppTemplate.xcodeproj \ |
| 11 | + -scheme "NativeAppTemplate" \ |
| 12 | + -configuration Debug \ |
| 13 | + -sdk iphonesimulator \ |
| 14 | + -destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2' \ |
| 15 | + build |
| 16 | + |
| 17 | +# Build for Release |
| 18 | +xcodebuild -project NativeAppTemplate.xcodeproj \ |
| 19 | + -scheme "NativeAppTemplate" \ |
| 20 | + -configuration Release \ |
| 21 | + -sdk iphonesimulator \ |
| 22 | + -destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2' \ |
| 23 | + build |
| 24 | +``` |
| 25 | + |
| 26 | +### Running Tests |
| 27 | +```bash |
| 28 | +# Run all tests |
| 29 | +xcodebuild -project NativeAppTemplate.xcodeproj \ |
| 30 | + -scheme "NativeAppTemplate" \ |
| 31 | + -sdk iphonesimulator \ |
| 32 | + -destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.2' \ |
| 33 | + test |
| 34 | +``` |
| 35 | + |
| 36 | +### Linting |
| 37 | +```bash |
| 38 | +# Run SwiftLint (must be installed via: brew install swiftlint) |
| 39 | +cd NativeAppTemplate && swiftlint |
| 40 | + |
| 41 | +# Run SwiftLint with strict mode (as in CI) |
| 42 | +cd NativeAppTemplate && swiftlint --strict |
| 43 | +``` |
| 44 | + |
| 45 | +## Architecture Overview |
| 46 | + |
| 47 | +### MVVM with Observable Pattern |
| 48 | +The app uses iOS 17's `@Observable` macro for state management with clean separation between: |
| 49 | +- **Views**: SwiftUI views (99% SwiftUI, UIKit only for mail view) |
| 50 | +- **ViewModels**: Observable state containers that bridge views and data |
| 51 | +- **Models**: Domain objects and data structures |
| 52 | +- **Repositories**: Data access layer implementing CRUD operations |
| 53 | + |
| 54 | +### Core Components |
| 55 | + |
| 56 | +**Data Flow Architecture**: |
| 57 | +1. **SessionController** (`/Sessions/SessionController.swift`): Manages authentication state and user sessions |
| 58 | +2. **DataManager** (`/Data/DataManager.swift`): Central orchestrator that manages all repositories |
| 59 | +3. **Repositories**: Each entity has its own repository (e.g., `ShopRepository`, `ItemTagRepository`) |
| 60 | +4. **Services**: Network layer abstraction with protocol-based design |
| 61 | +5. **MessageBus** (`/MessageBus.swift`): Event communication system for decoupled components |
| 62 | + |
| 63 | +**Networking Architecture**: |
| 64 | +- JSON API format with custom adapters (`/Networking/Adapters/`) |
| 65 | +- Service layer pattern (`/Networking/Services/`) |
| 66 | +- Request/Response models (`/Networking/Requests/`, `/Networking/Responses/`) |
| 67 | +- Error handling with typed errors (`/Models/AppError.swift`) |
| 68 | + |
| 69 | +### Key Features Implementation |
| 70 | + |
| 71 | +**NFC Support**: |
| 72 | +- Tag reading/writing capabilities (`/NFC/`) |
| 73 | +- Background tag reading support |
| 74 | +- Application-specific tag data format |
| 75 | + |
| 76 | +**Offline Support**: |
| 77 | +- Network monitoring (`/Networking/NetworkMonitor.swift`) |
| 78 | +- Keychain storage for secure data persistence |
| 79 | + |
| 80 | +**Configuration**: |
| 81 | +- Central configuration in `Constants.swift` |
| 82 | +- API endpoints, UI strings, and app constants |
| 83 | +- Environment-specific settings (scheme, domain, port) |
| 84 | + |
| 85 | +### Project Structure |
| 86 | +``` |
| 87 | +NativeAppTemplate/ |
| 88 | +├── App.swift # App entry point |
| 89 | +├── MainView.swift # Root view |
| 90 | +├── Data/ # Data layer (repositories, ViewModels) |
| 91 | +├── Models/ # Domain models |
| 92 | +├── Networking/ # API layer |
| 93 | +├── UI/ # SwiftUI views by feature |
| 94 | +├── Sessions/ # Authentication |
| 95 | +├── Persistence/ # Keychain storage |
| 96 | +├── Utilities/ # Helpers and extensions |
| 97 | +└── NFC/ # NFC functionality |
| 98 | +``` |
| 99 | + |
| 100 | +### Dependencies (Swift Package Manager) |
| 101 | +- KeychainAccess (4.2.2) - Secure credential storage |
| 102 | +- SwiftyJSON (5.0.2) - JSON parsing |
| 103 | +- Swift Collections (1.1.4) - Additional data structures |
| 104 | + |
| 105 | +### Testing |
| 106 | +Uses Swift Testing framework with `@Test` attribute. Tests are organized by component type (models, adapters, networking). |
0 commit comments