not convert return expression of type '[UIView : ViewAnnotationOptions]' to return type 'Dictionary<String, Optional<JSONValue>>.RawValue' (aka 'Dictionary<String, Optional<Any>>')
Environment
- Dev OS: [e.g. OSX 15.1.1]
- Xcode: [Version 16.2 ]
- @rnmapbox/maps version: [eg. 10.1.33]
- React Native version: [eg. 0.76.3]
- Expo version: [eg. 52.0.7]
Steps to reproduce
If the build in Xcode or Expo fails and shows the following error: Cannot convert return expression of type '[UIView : ViewAnnotationOptions]' to return type 'Dictionary<String, Optional<JSONValue>>.RawValue' (aka 'Dictionary<String, Optional<Any>>')
The error originates from lines 76-82 in the Pods->MapboxMaps->ViewAnnotationManager file.
/// The complete list of annotations associated with the receiver.
@available(*, deprecated, message: "Use ViewAnnotation")
public var annotations: [UIView: ViewAnnotationOptions] {
idsByView.compactMapValues { [mapboxMap] id in
try? mapboxMap.options(forViewAnnotationWithId: id)
}
}
It’s just a type error, and I bypassed this error using the following method.
/// The complete list of annotations associated with the receiver.
@available(*, deprecated, message: "Use ViewAnnotation")
public var annotations: [UIView: ViewAnnotationOptions] {
return [:]
}
The annotations property has been deprecated, which might be an issue with the mapbox-gl version.
facing the same problem using rn 0.76.6
bypassing by using the code from mapbox-maps-ios
/// The complete list of annotations associated with the receiver.
@available(*, deprecated, message: "Use ViewAnnotation")
public var annotations: [UIView: ViewAnnotationOptions] {
let values = idsByView.compactMapValues { [mapboxMap] id in
try? mapboxMap.options(forViewAnnotationWithId: id)
}
return values
}
Would you please add more details how to apply the correction, assuming Expo configs?
you can add a postinstall hook to your podfile @estoilkov
installer.pods_project.targets.each do |target|
if target.name == 'MapboxMaps'
file_path = 'Pods/MapboxMaps/Sources/MapboxMaps/Annotations/ViewAnnotationManager.swift'
file_content = File.read(file_path)
if file_content.include?('idsByView.compactMapValues { [mapboxMap] id in')
new_content = file_content.gsub(
/public var annotations: \[UIView: ViewAnnotationOptions\] \{\n\s+idsByView\.compactMapValues \{ \[mapboxMap\] id in\n\s+try\? mapboxMap\.options\(forViewAnnotationWithId: id\)\n\s+\}\n\s+\}/,
"public var annotations: [UIView: ViewAnnotationOptions] {\n let values = idsByView.compactMapValues { [mapboxMap] id in\n try? mapboxMap.options(forViewAnnotationWithId: id)\n }\n return values\n }")
File.write(file_path, new_content)
puts "Fixed ViewAnnotationManager.swift in MapboxMaps pod"
end
end
end
Encountering the same issue with non-expo react native, with rnmapbox/maps 10.1.37
Regarding the postinstall hook, this resulted in a permissions issue for me:
[!] An error occurred while processing the post-install hook of the Podfile.
Permission denied @ rb_sysopen - Pods/MapboxMaps/Sources/MapboxMaps/Annotations/ViewAnnotationManager.swift
Sounds like I'd have to manually change permissions on this file to get the hook to work properly..
I am encountering this issue when building using Expo's eas build.
Environment
- Dev OS: [e.g. OSX 15.1.1]
- Xcode: [Version 16.2 ]
- @rnmapbox/maps version: [eg. 10.1.33]
- React Native version: [eg. 0.76.3]
- Expo version: [eg. 52.0.7]
Steps to reproduce
If the build in Xcode or Expo fails and shows the following error: Cannot convert return expression of type '[UIView : ViewAnnotationOptions]' to return type 'Dictionary<String, Optional>.RawValue' (aka 'Dictionary<String, Optional>')
The error originates from lines
76-82in thePods->MapboxMaps->ViewAnnotationManagerfile./// The complete list of annotations associated with the receiver. @available(*, deprecated, message: "Use ViewAnnotation") public var annotations: [UIView: ViewAnnotationOptions] { idsByView.compactMapValues { [mapboxMap] id in try? mapboxMap.options(forViewAnnotationWithId: id) } } It’s just a type error, and I bypassed this error using the following method.
/// The complete list of annotations associated with the receiver. @available(*, deprecated, message: "Use ViewAnnotation") public var annotations: [UIView: ViewAnnotationOptions] { return [:] } The annotations property has been deprecated, which might be an issue with the
mapbox-glversion.
Could you tell us more about how you implemented this fix? How did you apply it? Did you build locally? How did you get EAS to make these changes? }
Implemented solution
I resolved this through the approach:
- Updated the Mapbox SDK version in
app.config.js:
// app.config.js
[
"@rnmapbox/maps",
{
RNMapboxMapsImpl: "mapbox",
RNMapboxMapsVersion: "11.8.0", // Updated from 11.4.0
RNMapboxMapsDownloadToken: process.env.MAPBOX_DOWNLOAD_TOKEN,
},
],
Implemented solution
I resolved this through the approach:
- Updated the Mapbox SDK version in
app.config.js:// app.config.js [ "@rnmapbox/maps", { RNMapboxMapsImpl: "mapbox", RNMapboxMapsVersion: "11.8.0", // Updated from 11.4.0 RNMapboxMapsDownloadToken: process.env.MAPBOX_DOWNLOAD_TOKEN, }, ],
Where is place of this file app.config.js?
Where is place of this file app.config.js?
Yes, In plugin key
Should be fixed by recent MapboxMaps version