Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error in ViewAnnotationManager.swift when running React Native app on iOS 18 #3640

Open
guneyural opened this issue Sep 30, 2024 · 7 comments
Labels
bug 🪲 Something isn't working

Comments

@guneyural
Copy link

Mapbox Implementation

Mapbox

Mapbox Version

= 11.4.0

React Native Version

0.74.3

Platform

iOS

@rnmapbox/maps version

^10.0.0-beta.28

Standalone component to reproduce

Steps to Reproduce

1. Upgrade iOS version to 18 and Xcode to 16.0
2. Install the latest version of rnmapbox/maps and MapboxMaps.
3. Run the React Native app using `npm run ios`.
import React from 'react';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@rnmapbox/maps';

const aLine = {
  type: 'LineString',
  coordinates: [
    [-74.00597, 40.71427],
    [-74.00697, 40.71527],
  ],
};

class BugReportExample extends React.Component {
  render() {
    return (
      <MapView style={{flex: 1}}>
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
      </MapView>
    );
  }
}

Observed behavior and steps to reproduce

I am experiencing an issue when running my React Native application using the rnmapbox/maps library on iOS 18 and xcode 16.0

Before the update there was no problem.

The build fails with a Swift type conversion error in ViewAnnotationManager.swift.

❌  (ios/Pods/MapboxMaps/Sources/MapboxMaps/Annotations/ViewAnnotationManager.swift:79:19)

  77 |     @available(*, deprecated, message: "Use ViewAnnotation")
  78 |     public var annotations: [UIView: ViewAnnotationOptions] {
> 79 |         idsByView.compactMapValues { [mapboxMap] id in
     |                   ^ cannot convert return expression of type '[UIView : ViewAnnotationOptions]' to return type 'Dictionary<String, Optional<JSONValue>>.RawValue' 
  80 |             try? mapboxMap.options(forViewAnnotationWithId: id)
  81 |         }
  82 |     }

The build fails due to an error related to ViewAnnotationManager.swift in the MapboxMaps library. The error points to a type conversion issue between [UIView : ViewAnnotationOptions] and Dictionary<String, Optional>.RawValue.

Expected behavior

The application should build successfully and work as expected on iOS 18 and xcode 16.0

Notes / preliminary analysis

No response

Additional links and references

No response

@guneyural guneyural added the bug 🪲 Something isn't working label Sep 30, 2024
@VedantTapadia-RisingTide

+1

@dadudad1
Copy link

dadudad1 commented Oct 1, 2024

a quick fix until the official release... change the annotation variable to:
public var annotations: [String: Optional<Any>] {
var result: [String: Optional<Any>] = [:]
for (view, options) in idsByView.compactMapValues({ [mapboxMap] id in try? mapboxMap.options(forViewAnnotationWithId: id) }) {
let key = String(describing: view)
result[key] = options
}
return result
}

@VedantTapadia-RisingTide

Which file does this change go with?

@dadudad1
Copy link

dadudad1 commented Oct 1, 2024

in ios/Pods/MapboxMaps/Sources/MapboxMaps/Annotations/ViewAnnotationManager.swift as specified in the issue

I am using version 10.1.31

@ChickenBone
Copy link

+1

2 similar comments
@kckunal2612
Copy link

+1

@rprvnraj
Copy link

rprvnraj commented Oct 2, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants