Source profileQuality 96/100

mapbox/mapbox-agent-skills/skills/mapbox-ios-patterns/SKILL.md

mapbox-ios-patterns

Official integration patterns for Mapbox Maps SDK on iOS. Covers installation, adding markers, user location, custom data, styles, camera control, and featureset interactions. Based on official Mapbox documentation.

Source repository stars
72
Declared platforms
0
Static risk flags
0
Last source update
2026-08-19
Source checked
2026-08-25

Decision brief

What it does: where it fits

Official patterns for integrating Mapbox Maps SDK v11 on iOS with Swift, SwiftUI, and UIKit.

Best for

    Not for

    • Map Not Displaying
    • Style Not Loading

    Compatibility matrix

    Platform support, with evidence labels

    PlatformStatusEvidenceWhat to check
    CodexNot declaredNo explicit evidencePortability before use
    Claude CodeNot declaredNo explicit evidencePortability before use
    CursorNot declaredNo explicit evidencePortability before use
    Gemini CLINot declaredNo explicit evidencePortability before use
    Open the compatibility checker

    Installation

    Inspect first. Install second.

    The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

    Source-detected install commandSource
    npx skills add https://github.com/mapbox/mapbox-agent-skills --skill "skills/mapbox-ios-patterns"
    Safe inspection promptEditorial

    Inspect the Agent Skill "mapbox-ios-patterns" from https://github.com/mapbox/mapbox-agent-skills/blob/304d4eb7b0c61d999ce1ad690fe368680e2e5993/skills/mapbox-ios-patterns/SKILL.md at commit 304d4eb7b0c61d999ce1ad690fe368680e2e5993. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

    Workflow

    What the source asks the agent to do

    1. 01

      Installation & Setup

      Add your public token to Info.plist:

      iOS 14+Xcode 15+Swift 5.9+
    2. 02

      Step 1: Configure Access Token

      Add your public token to Info.plist:

      Add your public token to Info.plist:Get your token: Sign in at mapbox.com
    3. 03

      Step 2: Add Swift Package Dependency

      1. File → Add Package Dependencies 2. Enter URL: https://github.com/mapbox/mapbox-maps-ios.git 3. Version: "Up to Next Major" from 11.0.0 4. Verify four dependencies appear: MapboxCommon, MapboxCoreMaps, MapboxMaps, Turf

      File → Add Package DependenciesEnter URL: https://github.com/mapbox/mapbox-maps-ios.gitVersion: "Up to Next Major" from 11.0.0
    4. 04

      Requirements

      iOS 14+

      iOS 14+Xcode 15+Swift 5.9+
    5. 05

      Map Initialization

      Review the “Map Initialization” section in the pinned source before continuing.

      Review and apply the “Map Initialization” source section.

    Permission review

    Static risk signals and limitations

    No configured static risk pattern was detected

    This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

    Evidence record

    Why each signal appears

    EvidenceSourceComputedTestedEditorial
    SignalValueEvidence typeMeaning
    Quality score96/100ComputedDocumentation, specificity, maintenance, and trust rules
    Repository stars72SourceRepository attention, not individual Skill quality
    Compatibility0 platformsSourceDeclared in the catalog source record
    Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

    Pinned source

    Provenance and original SKILL.md

    Repository
    mapbox/mapbox-agent-skills
    Skill path
    skills/mapbox-ios-patterns/SKILL.md
    Commit
    304d4eb7b0c61d999ce1ad690fe368680e2e5993
    License
    MIT
    Collected
    2026-08-25
    Default branch
    main
    View the original SKILL.md

    Mapbox iOS Integration Patterns

    Official patterns for integrating Mapbox Maps SDK v11 on iOS with Swift, SwiftUI, and UIKit.

    Use this skill when:

    • Installing and configuring Mapbox Maps SDK for iOS
    • Adding markers and annotations to maps
    • Showing user location and tracking with camera
    • Adding custom data (GeoJSON) to maps
    • Working with map styles, camera, or user interaction
    • Handling feature interactions and taps

    Official Resources:


    Installation & Setup

    Requirements

    • iOS 14+
    • Xcode 15+
    • Swift 5.9+
    • Free Mapbox account

    Step 1: Configure Access Token

    Add your public token to Info.plist:

    <key>MBXAccessToken</key>
    <string>pk.your_mapbox_token_here</string>
    

    Get your token: Sign in at mapbox.com

    Step 2: Add Swift Package Dependency

    1. File → Add Package Dependencies
    2. Enter URL: https://github.com/mapbox/mapbox-maps-ios.git
    3. Version: "Up to Next Major" from 11.0.0
    4. Verify four dependencies appear: MapboxCommon, MapboxCoreMaps, MapboxMaps, Turf

    Alternative: CocoaPods or direct download (install guide)


    Map Initialization

    SwiftUI Pattern

    Basic map:

    import SwiftUI
    import MapboxMaps
    
    struct ContentView: View {
        @State private var viewport: Viewport = .camera(
            center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194),
            zoom: 12
        )
    
        var body: some View {
            Map(viewport: $viewport)
                .mapStyle(.standard)
        }
    }
    

    With ornaments:

    Map(viewport: $viewport)
        .mapStyle(.standard)
        .ornamentOptions(OrnamentOptions(
            scaleBar: .init(visibility: .visible),
            compass: .init(visibility: .adaptive),
            logo: .init(position: .bottomLeading)
        ))
    

    UIKit Pattern

    import UIKit
    import MapboxMaps
    
    class MapViewController: UIViewController {
        private var mapView: MapView!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            let options = MapInitOptions(
                cameraOptions: CameraOptions(
                    center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194),
                    zoom: 12
                )
            )
    
            mapView = MapView(frame: view.bounds, mapInitOptions: options)
            mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
            view.addSubview(mapView)
    
            mapView.mapboxMap.loadStyle(.standard)
        }
    }
    

    Add Markers

    The SDK offers three ways to place a point on the map. Pick the simplest one that fits.

    Agent note: A SwiftUI Mapbox sketch is incomplete without at least one annotation (Marker, PointAnnotation, or MapViewAnnotation). Do not ship a bare Map { } with no pin.

    Which API should I use?

    APIUse it whenPlatformsNotes
    Marker (Markers API)You need a default pin and don't have a custom image assetSwiftUI onlyNo image assets required. Experimental SPI — needs @_spi(Experimental) import MapboxMaps. Best < 100 markers.
    PointAnnotationYou have a custom image and want layer-level placementSwiftUI + UIKitBacked by a symbol layer, so it scales well to hundreds of markers. Accepts any UIImage that UIKit can render.
    View annotations (ViewAnnotation / MapViewAnnotation)You want to render a full native view (card, badge, animated content) anchored to a coordinateSwiftUI + UIKitSwiftUI uses MapViewAnnotation; UIKit uses mapView.viewAnnotations with a ViewAnnotation. Each annotation is a real view — costs more than PointAnnotation at scale.

    For hundreds or thousands of features, use a style layer (SymbolLayer on a GeoJSONSource) instead of annotations.

    Markers API (recommended for simple cases, SwiftUI)

    import SwiftUI
    @_spi(Experimental) import MapboxMaps
    
    struct ContentView: View {
        var body: some View {
            Map {
                Marker(coordinate: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194))
                    .color(.red)
                    .text("San Francisco")
            }
        }
    }
    

    Multiple markers from a collection:

    Map {
        ForEvery(locations, id: \.id) { location in
            Marker(coordinate: location.coordinate)
                .color(.red)
                .text(location.name)
        }
    }
    

    Scaling note. Marker and PointAnnotation each create their own view or symbol entry per pin — fine up to about 100 markers. For larger datasets (hundreds or thousands of features — common with open-ended GeoJSON feeds), load the data into a GeoJSONSource and render it with a SymbolLayer instead. That scales to thousands of features and enables clustering.

    PointAnnotation (custom image)

    SwiftUI:

    Map(viewport: $viewport) {
        PointAnnotation(coordinate: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194))
            .image(.init(image: UIImage(named: "marker")!, name: "marker"))
    }
    

    UIKit:

    // Create annotation manager (once, reuse for updates)
    var pointAnnotationManager = mapView.annotations.makePointAnnotationManager()
    
    // Create marker
    var annotation = PointAnnotation(coordinate: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194))
    annotation.image = .init(image: UIImage(named: "marker")!, name: "marker")
    annotation.iconAnchor = .bottom
    
    // Add to map
    pointAnnotationManager.annotations = [annotation]
    

    Multiple markers:

    let annotations = locations.map { coordinate in
        var annotation = PointAnnotation(coordinate: coordinate)
        annotation.image = .init(image: UIImage(named: "marker")!, name: "marker")
        return annotation
    }
    
    pointAnnotationManager.annotations = annotations
    

    Show User Location

    Step 1: Add location permission to Info.plist:

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Show your location on the map</string>
    

    Step 2: Request permissions and show location:

    import CoreLocation
    
    // Request permissions
    let locationManager = CLLocationManager()
    locationManager.requestWhenInUseAuthorization()
    
    // Show user location puck
    mapView.location.options.puckType = .puck2D()
    mapView.location.options.puckBearingEnabled = true
    

    Performance Best Practices

    Reuse Annotation Managers

    // ❌ Don't create new managers repeatedly
    func updateMarkers() {
        let manager = mapView.annotations.makePointAnnotationManager()
        manager.annotations = markers
    }
    
    // ✅ Create once, reuse
    let pointAnnotationManager: PointAnnotationManager
    
    init() {
        pointAnnotationManager = mapView.annotations.makePointAnnotationManager()
    }
    
    func updateMarkers() {
        pointAnnotationManager.annotations = markers
    }
    

    Batch Annotation Updates

    // ✅ Update all at once
    pointAnnotationManager.annotations = newAnnotations
    
    // ❌ Don't update one by one
    for annotation in newAnnotations {
        pointAnnotationManager.annotations.append(annotation)
    }
    

    Memory Management

    // Use weak self in closures
    mapView.gestures.onMapTap.observe { [weak self] context in
        self?.handleTap(context.coordinate)
    }.store(in: &cancelables)
    
    // Clean up on deinit
    deinit {
        cancelables.forEach { $0.cancel() }
    }
    

    Use Standard Style

    // ✅ Standard style is optimized and recommended
    .mapStyle(.standard)
    
    // Use other styles only when needed for specific use cases
    .mapStyle(.standardSatellite) // Satellite imagery
    

    Troubleshooting

    Map Not Displaying

    Check:

    1. MBXAccessToken in Info.plist
    2. ✅ Token is valid (test at mapbox.com)
    3. ✅ MapboxMaps framework imported
    4. ✅ MapView added to view hierarchy
    5. ✅ Correct frame/constraints set

    Style Not Loading

    mapView.mapboxMap.onStyleLoaded.observe { [weak self] _ in
        print("Style loaded successfully")
        // Add layers and sources here
    }.store(in: &cancelables)
    

    Performance Issues

    • Use .standard style (recommended and optimized)
    • Limit visible annotations to viewport
    • Reuse annotation managers
    • Avoid frequent style reloads
    • Batch annotation updates

    Reference Files

    Load these references when the task requires deeper patterns:

    • references/annotations.md — Circle, Polyline, Polygon Annotations
    • references/location-tracking.md — Camera Follow User + Get Current Location
    • references/custom-data.md — GeoJSON: Lines, Polygons, Points, Update/Remove
    • references/camera-styles.md — Camera Control + Map Styles
    • references/interactions.md — Featureset Interactions, Custom Layer Taps, Long Press, Gestures

    Additional Resources

    Frequently asked questions

    What to verify before installation and use

    What does the mapbox-ios-patterns source document cover?

    Official patterns for integrating Mapbox Maps SDK v11 on iOS with Swift, SwiftUI, and UIKit.

    How do I install mapbox-ios-patterns?

    The source record exposes this install command: npx skills add https://github.com/mapbox/mapbox-agent-skills --skill "skills/mapbox-ios-patterns". Inspect the command and pinned source before running it.

    Alternatives

    Compare before choosing

    Computed 100147

    oaustegard/claude-skills

    featuring

    Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre

    Computed 99238

    enuno/unifi-mcp-server

    unifi-mcp-tool-builder

    Specialized guide for adding new MCP tools to the UniFi MCP Server following project standards, UniFi API patterns, and test-driven development practices. Use when implementing new UniFi Network Controller features as MCP tools.

    Computed 9970

    PaulRBerg/agent-skills

    skill-writing

    Create/scaffold/init a project-local agent skill under `.agents/skills` in an ordinary repository; defer to repository instructions that define a source catalog and lifecycle.

    Computed 9916

    NintendaDev/unikit-ai

    unikit-docs

    Generate and maintain the project's TECHNICAL documentation from its codebase — scans the project structure, tech stack, and module boundaries, then writes a lean README landing page plus detailed topic pages (architecture, modules, setup, build, APIs), only the docs that are relevant. Use whenever the user wants to create, update, or validate documentation of the CODE or the project itself, e.g. "generate documentation", "create docs", "write the README", "update the project docs", "document th