-
Notifications
You must be signed in to change notification settings - Fork 190
Description
Environment
- Xcode: 16.1
- iOS deployment target: 15.1
- Build target: iOS Simulator (Debug; also reproducible on device builds)
- React Native stack (for context):
- Expo SDK: 54.0.22
- React Native: 0.82.1
- React: 19.2.0
- Hermes: enabled
- @rnmapbox/maps: 10.2.6
Platform
- Platform: iOS
- Language: Swift
- Build system: CocoaPods + xcodebuild (React Native / Expo integration)
SDK versions
- Mapbox Maps iOS: 10.17.0 (via CocoaPods, transitive dependency from @rnmapbox/maps 10.2.6)
- MapboxCoreMaps: 10.17.0
- MapboxCommon: 23.9.2
- MapboxMobileEvents: 1.0.10
- Turf: 2.7.0
Observed behavior and steps to reproduce
Building a project that includes MapboxMaps 10.17.0 fails on Xcode 16.1 with a Swift type mismatch originating in ViewAnnotationManager.swift. The compiler infers a dictionary of type [UIView: ViewAnnotationOptions] where the code expects [String: Any?], causing a hard compile error.
Replacing the computed property that uses a compactMap/transform chain with an explicit dictionary construction (with explicit types) resolves the issue without changing behavior.
Steps to reproduce
- In a fresh iOS project (or React Native/Expo iOS app) add @rnmapbox/maps 10.2.6, which installs MapboxMaps 10.17.0 via CocoaPods.
- pod install
- Build with Xcode 16.1 or via xcodebuild for iOS Simulator (Debug or Release).
Expected behavior
The project compiles successfully.
Notes / preliminary analysis
Actual behavior
Compilation fails in MapboxMaps with a type mismatch error.
Error logs
Pods/MapboxMaps/Sources/MapboxMaps/Annotations/ViewAnnotationManager.swift:67:XX: error: cannot convert return expression of type '[UIView : ViewAnnotationOptions]' to return type '[String : Any?]'
Notes:
- The error points at the computed property that constructs a dictionary using a compactMap/values transform.
- Under Xcode 16.1, Swift’s inference appears to resolve the dictionary as keyed by UIView with ViewAnnotationOptions values, conflicting with the function’s expected [String: Any?] return type.
Minimal code location
- File: Pods/MapboxMaps/Sources/MapboxMaps/Annotations/ViewAnnotationManager.swift
- Symbol: computed property building “annotations” for view annotations (uses a compactMap/values transformation)
Workaround (verified)
Implement the dictionary with explicit construction and types (avoid the compactMap/values chain). For example, conceptually:
// Before (approximate shape)
private var annotations: [String: Any?] {
// builds a dictionary via compactMap/values chain
}
// After (works on Xcode 16.1)
private var annotations: [String: Any?] {
var result: [String: Any?] = [:]
// explicitly iterate and insert with the desired key/value types
// (no behavior change; avoids inference mismatch)
return result
}Applying this change locally in the Pod source restores successful builds on Xcode 16.1.
Additional context
- The failure started when building with Xcode 16.1; earlier Xcode versions may not hit the same inference path.
- Our environment uses the prebuilt RN 0.82/Hermes toolchain. The issue appears isolated to Swift type inference in MapboxMaps rather than React Native integration.
- We confirmed the workaround by patching the Pod file post-install; the app builds and runs with Mapbox normally afterward.