maps icon indicating copy to clipboard operation
maps copied to clipboard

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

Open guneyural opened this issue 1 year ago • 13 comments

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<JSONValue>>.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 avatar Sep 30 '24 18:09 guneyural

+1

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 }

dadudad1 avatar Oct 01 '24 12:10 dadudad1

Which file does this change go with?

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

I am using version 10.1.31

dadudad1 avatar Oct 01 '24 13:10 dadudad1

+1

ChickenBone avatar Oct 02 '24 14:10 ChickenBone

+1

kckunal2612 avatar Oct 02 '24 14:10 kckunal2612

+1

rprvnraj avatar Oct 02 '24 16:10 rprvnraj

Same issues

kbqdev avatar Oct 09 '24 04:10 kbqdev

+1

artanisdesign avatar Oct 10 '24 09:10 artanisdesign

+1 from an expo user when building a development client

"RNMapboxMapsVersion": "11.4.0", "@rnmapbox/maps": "^10.1.3", "react-native": "0.73.2", "expo": "50.0.14",

matthewhausmantrellus avatar Oct 10 '24 20:10 matthewhausmantrellus

@dadudad1 To patch the file, I am struggling about how to. Typically, if I want to patch a file temporarily, I would use 'yarn patch', however, in this case, the file in under ios/Pods folder, which is not part of the repo (something that generated by Cocapods?). So, I don't know how to apply the temp fix.

ShaneZhengNZ avatar Oct 17 '24 02:10 ShaneZhengNZ

Any update?

martmalo avatar Oct 19 '24 08:10 martmalo

Still no official fix from maintainers. Using @dadudad1 solution solves the issue.

guneyural avatar Oct 20 '24 16:10 guneyural

@guneyural I doubt it unless you eject your Expo project. With the reasons that I mentioned above, I am struggling to find a proper solution to apply @dadudad1 solution.

Basically, don't build with Xcode 16, then you should be fine. Wait for the official fix.

ShaneZhengNZ avatar Oct 21 '24 01:10 ShaneZhengNZ

@matthewhausmantrellus did you find a fix for expo? I'm in the same boat as you :(

vulliza avatar Oct 21 '24 19:10 vulliza

@matthewhausmantrellus did you find a fix for expo? I'm in the same boat as you :(

npx expo run:ios. There are a number of additional steps potentially depending on the user

matthewhausmantrellus avatar Oct 21 '24 22:10 matthewhausmantrellus

@matthewhausmantrellus I don't understand why do you need additional steps? I am using the same Expo SDK version. I can build the development client in EAS (not locally) with the sdk-50 compatible iOS image.

ShaneZhengNZ avatar Oct 22 '24 00:10 ShaneZhengNZ

This build error occurs when native SDK version is v11. Therefore just remove RNMapboxMapsVersion from your app.json if you have no reason to use v11.

https://rnmapbox.github.io/docs/install

yudai524 avatar Oct 23 '24 04:10 yudai524

This build error occurs when native SDK version is v11. Therefore just remove RNMapboxMapsVersion from your app.json if you have no reason to use v11.

There is an PrivacyInfo.xcprivacy issue with rnmapbox. In case of expo it seems the easiest solution is selecting v11, even if the app itself uses v10. See https://github.com/rnmapbox/maps/issues/3447#issuecomment-2092995008

Gys avatar Oct 27 '24 08:10 Gys

I think this is addressed by 10.1.33

mfazekas avatar Nov 03 '24 10:11 mfazekas

Still having this issue with 10.1.33 unfortunately :/

TobiDevloft avatar Nov 06 '24 14:11 TobiDevloft

+1

pavlo-sodtrack avatar Nov 06 '24 18:11 pavlo-sodtrack

@mfazekas Am still having same issue in 10.1.33. Kindly help rectify.

Thanks

Rashotech avatar Nov 06 '24 19:11 Rashotech

Can someone open a pr with changes, please?

mfazekas avatar Nov 12 '24 13:11 mfazekas

This is all fixed for me by switching the mapbox maps version to 11.8

mpiannucci avatar Nov 13 '24 17:11 mpiannucci

Can someone open a pr with changes, please?

https://github.com/rnmapbox/maps/pull/3696

I'm using new architecture, Expo SDK 52. Build fails with 11.4, succeeds with 11.8. Hope this PR helps.

RyanTG avatar Nov 15 '24 20:11 RyanTG

you have to update "RNMapboxMapsVersion": "11.8.0"

nicolofranceschi avatar Nov 22 '24 17:11 nicolofranceschi

Changing in app.json to:

"RNMapboxMapsVersion": "11.8.0"

fixed the problem. Thank you!

you have to update "RNMapboxMapsVersion": "11.8.0"

@nicolofranceschi

eybel avatar Feb 04 '25 15:02 eybel

I have found a magical combination and fixed maps in both - IOS and android.

So the secret combination is

  • Xcode 16.3,
  • iOS emulator 16.0,
  • device iPhone 16 Pro IOS 18.5, - you have to enable toggles in emulator's Settings => Developer
  • @rnmapbox/maps 10.1.39
  • "RNMapboxMapsVersion": "11.8.0" in app.json
  • react-native 0.79.4
  • expo 53.0.13 and all recommended package versions.

xcode before 16.3 fails with Network Request error after pending request fails on timeout, 16.4 has issues with https3 caching xcode 26 has issues with building android at this moment so that is not an option yet.

JustFly1984 avatar Jun 27 '25 20:06 JustFly1984