mapkit
Implement, review, or improve maps and location features in iOS/macOS apps using MapKit and CoreLocation. Use when working with Map views, annotations, markers, polylines, user location tracking, geocoding, reverse geocoding, search/autocomplete, directions and routes, geofencing, region monitoring, CLLocationUpdate async streams, or location authorization flows. Also use when working with maps, coordinates, addresses, places, directions, distance calculations, or location-based features in Swif
Security Assessment
About mapkit
A guide for implementing, reviewing, or improving maps and location features in iOS and macOS apps, targeting iOS 17+ with SwiftUI MapKit and the modern CoreLocation async APIs. It applies to Map views, annotations, markers, polylines, user-location tracking, geocoding and reverse geocoding, search and autocomplete, directions and routes, geofencing and region monitoring, CLLocationUpdate async streams, and location-authorization flows.
For views it uses Map with a MapContentBuilder closure containing Marker, Annotation, MapPolyline, MapPolygon, and MapCircle, a MapCameraPosition binding to move the camera, plus .mapStyle, .mapControls, interaction modes, and a selection binding. For location it replaces CLLocationManagerDelegate callbacks with the CLLocationUpdate.liveUpdates() async sequence, iterated in a stored, cancellable Task and filtered by accuracy, using a CLServiceSession on iOS 18+ and handling diagnostic states like denied authorization with a visible degraded path. CLMonitor handles geofencing.
Documented workflows cover adding a map with markers (requiring an NSLocationWhenInUseUsageDescription entry for location), tracking user location, searching places with MKLocalSearchCompleter using debounced input of at least 300ms before converting a completion to an MKLocalSearch.Request, and getting directions with an MKDirections.Request that sets a transportType, awaits calculate(), and draws the route as MapPolyline(route.polyline). Companion reference files hold fuller patterns for search, routes, Look Around, snapshots, and iOS 26+ place APIs, plus location lifecycle, geofencing, background location, testing, and privacy keys, and a review checklist closes the skill.
FAQ
What OS versions does the skill target?
iOS 17+ for SwiftUI MapKit and modern CoreLocation, with some capabilities noted for iOS 18+ and a PlaceDescriptor section for iOS 26+.
How do you track user location with the modern API?
Iterate CLLocationUpdate.liveUpdates() inside a stored, cancellable Task, filter updates by horizontal accuracy, and add NSLocationWhenInUseUsageDescription to Info.plist; on iOS 18+ use a CLServiceSession.
How is place search and autocomplete implemented?
Configure MKLocalSearchCompleter for suggestions, debounce input by at least 300ms, then convert the selected completion into an MKLocalSearch.Request for full results.
How do you display a route or directions?
Build an MKDirections.Request with source and destination MKMapItems, set the transportType, await MKDirections.calculate(), and draw the route with MapPolyline(route.polyline).
What is used for geofencing?
CLMonitor is used for geofencing and region monitoring.
Install mapkit
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
dpearson2699/swift-ios-skills