Docs / Setup / iOS / MapLibre

MapLibre setup

How to drive MapLibre Native through MapConductor. It needs no API key and is the fastest provider to get running; the look of the map comes from wherever the style JSON is served.

PACKAGE
ios-for-maplibre
API KEY
None
MIN iOS
15.1
VIEW
MapLibreMapView
Same provider, other platformsAndroidReact

Before you start

Xcode 15 or newer
A deployment target of iOS 15.1 or later
STEP 01

Add it with Swift Package Manager

Use File > Add Package Dependencies in Xcode and paste the package URL. The MapLibre Native SDK comes in automatically as a dependency.

Package URLSwift Package Manager
https://github.com/MapConductor/ios-for-maplibre
Package.swiftSwift
dependencies: [
    .package(url: "https://github.com/MapConductor/ios-sdk-core", from: "1.1.4"),
    .package(url: "https://github.com/MapConductor/ios-for-maplibre", from: "1.0.0"),
],
targets: [
    .target(
        name: "YourApp",
        dependencies: [
            .product(name: "MapConductorCore", package: "ios-sdk-core"),
            .product(name: "MapConductorForMapLibre", package: "ios-for-maplibre"),
        ]
    ),
]
STEP 02

Choose a style

MapLibre itself has no account and no key — but you do choose where tiles come from. With a commercial service such as MapTiler, that provider's key is embedded in the style JSON URL. MapConductor takes no part in tile-provider authentication.

ContentView.swiftSwift
// Built-in presets
mapState.mapDesignType = MapLibreDesign.OsmBright
mapState.mapDesignType = MapLibreDesign.OsmBrightJa
mapState.mapDesignType = MapLibreDesign.MapTilerTonerEn
mapState.mapDesignType = MapLibreDesign.DemoTiles
CAUTION
The demo styles are for verification only. In production, use your own or a commercial tile service and surface whatever attribution it requires.
STEP 03

Add the location permission (if needed)

If you use location, declare the purpose in Info.plist and request permission from the app.

Info.plistXML
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to display on the map</string>
LocationManager.swiftSwift
import CoreLocation

final class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
    private let manager = CLLocationManager()

    override init() {
        super.init()
        manager.delegate = self
    }

    func requestPermission() {
        manager.requestWhenInUseAuthorization()
    }
}

VERIFY

What you should see

Render the map with a style. Tiles loading, plus working zoom and pan, means you are done.

ContentView.swiftSwiftUI
import SwiftUI
import MapConductorCore
import MapConductorForMapLibre

struct ContentView: View {
    @StateObject var mapState = MapLibreViewState(
        mapDesignType: MapLibreDesign.OsmBright,
        cameraPosition: MapCameraPosition(
            position: GeoPoint(latitude: 35.6812, longitude: 139.7671),
            zoom: 12.0
        )
    )

    var body: some View {
        MapLibreMapView(state: mapState)
            .ignoresSafeArea()
    }
}

Map designs

Each MapLibreDesign wraps a style JSON URL. To use your own style, construct the type directly.

MapLibreDesign
Notes
DemoTiles
Lightweight demo tiles
OsmBright / OsmBrightEn / OsmBrightJa
OSM Bright, in default / English / Japanese label variants
MapTilerTonerEn / MapTilerTonerJa
The high-contrast Toner style
MapTilerBasicEn / MapTilerBasicJa
The pared-back Basic style

Troubleshooting

The map stays blank

  • Check the style JSON URL behind your chosen MapLibreDesign is reachable.
  • If you use a tile provider, verify the key embedded in the URL is still valid.
  • Check the deployment target is iOS 15.1 or later.

The build fails

  • Clean the build folder (Cmd+Shift+K).
  • Delete ~/Library/Developer/Xcode/DerivedData and rebuild.
  • Refresh the Swift Package Manager dependencies, and avoid mixing in CocoaPods.

Next

With MapLibreMapView on screen, overlays go on through the same shared API as every other provider.