Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions OTPKit/Sources/OTPKit/Core/Map/OTPMapProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ import SwiftUI
/// Protocol defining the interface for map operations that OTPKit requires.
/// Implementers of this protocol can provide their own map view (MKMapView, custom map, etc.)
/// while allowing OTPKit to control map content and interactions.
///
/// Main-actor isolated because every call arrives from a main-actor context — from
/// `MapCoordinator` inside the package, and from host UI code outside it — and because
/// conformances drive UI. Conforming types inherit this isolation, so the members of a
/// custom provider are main-actor isolated too.
///
/// Stating that here rather than leaving it implicit lets hosts building in the Swift 6
/// language mode with main-actor default isolation conform directly, instead of opting
/// the conformance out of isolation and hopping back in every method body.
@MainActor
public protocol OTPMapProvider: AnyObject {

// MARK: - Route Display
Expand Down
3 changes: 3 additions & 0 deletions OTPKit/Tests/SmokeTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func testFixturesCreatePlace() {
#expect(place.lon == -122.0)
}

// `MockMapProvider` conforms to `OTPMapProvider`, which is `@MainActor`, so the
// mock picks up that isolation and the test has to run there too.
@MainActor
@Test("MockMapProvider - tracks addRoute calls")
func mockMapProviderTracksRouteCalls() {
let mockMap = MockMapProvider()
Expand Down
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Both are Swift actors conforming to `APIService`; you can also implement `APISer

- **Transport modes:** pass `enabledTransportModes` to `OTPConfiguration` (defaults to transit, walk, bike, car). Rental modes like `.bikeRental` are opt-in and need an OTP 2.x server with rental data.
- **Theme:** pass an `OTPThemeConfiguration` to adjust colors.
- **Map behavior:** implement `OTPMapProvider` to control exactly how routes and stops render on your map.
- **Map behavior:** implement `OTPMapProvider` to control exactly how routes and stops render on your map. The protocol is `@MainActor`, so conformances inherit main-actor isolation — write your provider as main-actor isolated rather than opting the conformance out.

### Localization

Expand Down
Loading