- Created TournamentDTO and ScoreDTO for JSON serialization
- Created OpenAPI specification (openapi.yaml)
- Created API client service (TournamentAPIService.swift)
- Created sync UI (SyncTournamentView.swift)
- Updated TournamentView with sync button
- Created Vapor backend project structure
- Implemented API handler with in-memory storage
- Configured CORS for development
- Created comprehensive documentation
IMPORTANT: The iOS app won't build until you add these dependencies!
In Xcode:
-
Open
MahJong_Scores_4_0.xcodeproj -
Go to File > Add Package Dependencies
-
Add these three packages:
-
swift-openapi-runtime
- URL:
https://github.com/apple/swift-openapi-runtime - Version: 1.0.0 or later
- URL:
-
swift-openapi-urlsession
- URL:
https://github.com/apple/swift-openapi-urlsession - Version: 1.0.0 or later
- URL:
-
swift-openapi-generator
- URL:
https://github.com/apple/swift-openapi-generator - Version: 1.0.0 or later
- URL:
-
-
Select your app target
-
Go to Build Phases tab
-
Find or add Run Build Tool Plug-ins section
-
Click + button
-
Select OpenAPIGenerator from the list
- OpenAPI Generator plugin added to build phases
Ensure these files are added to your app target (check in File Inspector):
-
API/openapi.yaml -
API/openapi-generator-config.yaml -
API/TournamentAPIService.swift -
Model/DTO/TournamentDTO.swift -
Views/Tournament Views/SyncTournamentView.swift
cd /Users/rob/Projects/Swift/Apps/MahJongScoresBackend
swift package resolve
swift build
swift run- Backend builds successfully
- Backend starts on http://localhost:8081
- Can access http://localhost:8081/tournaments (should return empty array)
-
Clean build folder: Product > Clean Build Folder (⇧⌘K)
-
Build project (⌘B)
-
Run app (⌘R)
- iOS app builds successfully
- OpenAPI Generator creates Client types
- App launches without errors
- Sync button (↻) appears in toolbar
-
Create or select a tournament in the app
-
Tap sync button (↻)
-
Verify server URL: http://localhost:8081
-
Select a tournament
-
Tap Upload
- Sync view opens
- Can connect to server
- Can upload tournament
- Success message appears
curl http://localhost:8080/tournaments- Backend returns uploaded tournament data
This means OpenAPI Generator hasn't run yet.
Solution:
- Verify OpenAPI Generator plugin is in Build Phases
- Verify openapi.yaml and config file are in project
- Clean build folder (⇧⌘K)
- Build again (⌘B)
Backend server isn't running.
Solution:
cd /Users/rob/Projects/Swift/Apps/MahJongScoresBackend
swift runSolution:
cd /Users/rob/Projects/Swift/Apps/MahJongScoresBackend
swift package clean
swift package resolve
swift buildCheck Package.swift URLs and versions match exactly:
- vapor: 4.99.0 or later
- swift-openapi-generator: 1.0.0 or later
- swift-openapi-runtime: 1.0.0 or later
- swift-openapi-vapor: 1.0.0 or later
- Quick Start:
/Users/rob/Projects/Swift/Apps/QUICK_START_GUIDE.md - Implementation Details:
MahJong_Scores_4_0/IMPLEMENTATION_SUMMARY.md - API Documentation:
MahJong_Scores_4_0/API/README.md - Backend README:
/Users/rob/Projects/Swift/Apps/MahJongScoresBackend/README.md
Your setup is complete when:
- iOS app builds without errors
- Backend server starts successfully
- Can create tournaments in iOS app
- Can sync tournaments to backend
- Can verify data in backend with curl
- Connection status shows "Connected" in sync view
Once everything is working:
- Test thoroughly: Upload multiple tournaments, test all operations
- Review code: Understand how DTOs and API client work
- Customize: Modify openapi.yaml to add features
- Plan production: Consider authentication, database, HTTPS
- The backend uses in-memory storage (data lost on restart)
- Default server URL is http://localhost:8080
- Both iOS app and backend must use same openapi.yaml
- SwiftOpenAPI Generator runs automatically during build
- Backend logs appear in Terminal where you run
swift run
Good luck! 🎉