MapKit Setup
This section covers the setup process for MapKit integration with MapConductor.
Use this provider when you want Apple’s built-in map SDK with no external dependencies or API keys, and are targeting Apple platforms exclusively.
Prerequisites
Section titled “Prerequisites”- iOS development environment (Xcode 15+)
- iOS deployment target set to 15.0 or higher
MapKit is bundled with iOS and does not require an account or API key. MapKitMapView still supports sdkInitialize for parity with the other provider views.
Setup Steps
Section titled “Setup Steps”1. Swift Package Manager Configuration
Section titled “1. Swift Package Manager Configuration”Add MapConductorForMapKit to your Xcode project:
- In Xcode, go to File > Add Package Dependencies
- Enter the package URL:
https://github.com/MapConductor/ios-for-mapkit
2. Add Location Permissions (if needed)
Section titled “2. Add Location Permissions (if needed)”If your app uses location services, add the following key to Info.plist:
<key>NSLocationWhenInUseUsageDescription</key><string>We need your location to display on the map</string>Verification
Section titled “Verification”Build and run your app with the following code to verify the setup:
import SwiftUIimport MapConductorCoreimport MapConductorForMapKit
struct ContentView: View { @StateObject var mapState = MapKitViewState( mapDesignType: MapKitMapDesign.Standard, cameraPosition: MapCameraPosition( position: GeoPoint(latitude: 35.6812, longitude: 139.7671), zoom: 12.0 ) )
var body: some View { MapKitMapView( state: mapState, sdkInitialize: { // Optional. Called once before MKMapView is created. } ) .ignoresSafeArea() }}If the map displays without errors, your setup is working. Test basic interactions (zoom, pan) to confirm everything is functioning correctly.
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Map not displaying
- Verify iOS deployment target is 15.0 or higher
- Ensure
MapConductorForMapKitis correctly linked to your target
Build errors
- Clean build folder (Cmd+Shift+K)
- Delete derived data:
~/Library/Developer/Xcode/DerivedData - Rebuild project
Location Services
Section titled “Location Services”To enable location-based features, add location permissions to Info.plist (see step 2) and
request authorization in your app:
import CoreLocation
class LocationManager: NSObject, CLLocationManagerDelegate { let manager = CLLocationManager()
override init() { super.init() manager.delegate = self manager.requestWhenInUseAuthorization() }}Map Styles
Section titled “Map Styles”Use MapKitMapDesign static presets to set the map style:
// Standard street mapmapState.mapDesignType = MapKitMapDesign.Standard
// Satellite imagerymapState.mapDesignType = MapKitMapDesign.Satellite
// Satellite with roads and labelsmapState.mapDesignType = MapKitMapDesign.Hybrid
// Muted standard stylemapState.mapDesignType = MapKitMapDesign.MutedStandardNext Steps
Section titled “Next Steps”Once MapKit is properly configured, you can use MapKitMapView as described in the
Map View component documentation.
For more examples, see the Get Started tutorial.