Overview
Every destination implements theSyncDestination protocol:
Step-by-Step
We’ll use a hypothetical “CSV Export” destination as an example.1. Create the Destination File
Createios/HealthPush/Sources/Destinations/CSVExportDestination.swift:
2. Register in DestinationManager
Openios/HealthPush/Sources/Destinations/DestinationManager.swift and register the new type so the app knows it exists:
3. Add a Setup Screen
Createios/HealthPush/Sources/Views/Screens/CSVExportSetupScreen.swift:
4. Wire Up Navigation
InDestinationsScreen.swift, add the new destination to the “Add Destination” flow so users can select it.
5. Write Tests
Createios/HealthPush/Tests/CSVExportDestinationTests.swift:
6. Update Documentation
- Add the destination to the supported destinations table in
README.md - Update the roadmap in
README.mdto mark it as complete
Checklist
-
SyncDestinationprotocol implemented - Registered in
DestinationManager - Setup screen created with
testConnection()UI - Navigation wired up in
DestinationsScreen - Tests written and passing
- README updated
Tips
- Keep
sync()idempotent where possible — if the destination supports it, avoid duplicating data on re-sync. - Always implement
testConnection()meaningfully. Users rely on this to verify their setup before waiting for background syncs. - Use
Codableconformance to persist destination configuration via SwiftData. - Handle network errors gracefully in
sync()— throw descriptive errors so the sync engine can log useful failure reasons.