mapbox / mapbox-navigation-ios

Turn-by-turn navigation logic and UI in Swift on iOS
https://docs.mapbox.com/ios/navigation/
Other
860 stars 310 forks source link

[Bug]: Type of expression is ambiguous without more context #4341

Closed carlosriascoskoombea closed 1 year ago

carlosriascoskoombea commented 1 year ago

Mapbox Navigation SDK version

2.9.0

Steps to reproduce

Install the SDK via swift package manager

Expected behavior

The app should install the library without any error.

Actual behavior

The library is showing errors after upgrading the library MapboxDirections from version 2.8 to 2.9.

` InstructionPresenter.swift:134:56: type of expression is ambiguous without more context let attributedTextRepresentations = components.map { (component) -> NSAttributedString in


JunctionView.swift:59:73: type of expression is ambiguous without more context
        if case .guidanceView(let guidanceViewImageRepresentation, _) = guidanceView {
                                                                        ^~~~~~~~~~~~
JunctionView.swift:64:70: type of expression is ambiguous without more context
                guard let imageURL = guidanceViewImageRepresentation.imageURL else { return }
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
VisualInstructionComponent.swift:16:27: tuple pattern has the wrong length for tuple type '(image: GuidanceViewImageRepresentation, alternativeText: VisualInstruction.Component.TextRepresentation, kind: VisualInstruction.Component.GuidanceViewKind?)'
        case .guidanceView(let guidanceViewRepresentation, _):
                          ^
VisualInstructionComponent.swift:17:61: type of expression is ambiguous without more context
            guard let imageURL = guidanceViewRepresentation.imageURL else { return nil }`

Any suggestions?
Regards 

### Is this a one-time issue or a repeatable issue?

repeatable
S2Ler commented 1 year ago

Hi @carlosriascoskoombea, the issue with the project not building has been resolved. However you must reset the SPM cache from 'Xcode -> Packages -> Reset Package Cache.' This error was caused by unexpected changes in MapboxDirections v2.9.0, which affected the MapboxNavigation project.

kierancrown commented 2 months ago

Hi @S2Ler. I'm seeing this error when trying to build with Expo EAS.

I managed to fix the issue locally by replacing any usage of Expression with MapboxMaps. Expression. This issue occurs on iOS 18 so might not be an issue in older versions of iOS.

kierancrown commented 2 months ago

Hi @S2Ler. I'm seeing this error when trying to build with Expo EAS.

I managed to fix the issue locally by replacing any usage of Expression with MapboxMaps. Expression. This issue occurs on iOS 18 so might not be an issue in older versions of iOS.

Here is the patch file

diff --git a/node_modules/@rnmapbox/maps/android/.gitignore b/node_modules/@rnmapbox/maps/android/.gitignore
new file mode 100644
index 0000000..39fb081
--- /dev/null
+++ b/node_modules/@rnmapbox/maps/android/.gitignore
@@ -0,0 +1,9 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
+.externalNativeBuild
diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/Extensions/Array+asExpressions.swift b/node_modules/@rnmapbox/maps/ios/RNMBX/Extensions/Array+asExpressions.swift
index c2d652a..b3a3806 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/Extensions/Array+asExpressions.swift
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/Extensions/Array+asExpressions.swift
@@ -1,7 +1,7 @@
 import MapboxMaps

 internal extension Array where Element == Any {
-  func asExpression() throws -> Expression? {
+  func asExpression() throws -> MapboxMaps.Expression? {
     let filter = self
     if filter.count > 0 {
       let data = try JSONSerialization.data(withJSONObject: filter, options: .prettyPrinted)
diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModule.m b/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModule.m
index 1808393..ec00542 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModule.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModule.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTEventEmitter.h>

 @interface RCT_EXTERN_MODULE(RNMBXOfflineModule, RCTEventEmitter<RCTBridgeModule>)
diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.m b/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.m
index 550f67b..76da02d 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTEventEmitter.h>

 @interface RCT_EXTERN_MODULE(RNMBXOfflineModuleLegacy, RCTEventEmitter<RCTBridgeModule>)
diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXTileStoreModule.m b/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXTileStoreModule.m
index a98e102..e43be8f 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXTileStoreModule.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/Offline/RNMBXTileStoreModule.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTEventEmitter.h>

 @interface RCT_EXTERN_MODULE(RNMBXTileStoreModule, NSObject)
diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCalloutViewManager.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCalloutViewManager.m
index 62205d5..1db2ac4 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCalloutViewManager.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCalloutViewManager.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTViewManager.h>
 #import <Foundation/Foundation.h>

diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCameraViewManager.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCameraViewManager.m
index e23b10c..6a023fa 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCameraViewManager.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXCameraViewManager.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTViewManager.h>
 #import <Foundation/Foundation.h>

diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLocationModule.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLocationModule.m
index 8b89774..9f85c35 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLocationModule.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLocationModule.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTEventEmitter.h>

 @class RNMBXLocation;
diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLogging.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLogging.m
index d7c05de..f680b86 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLogging.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXLogging.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>

 @interface RCT_EXTERN_MODULE(RNMBXLogging, NSObject)

diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewContentManager.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewContentManager.m
index 72f9928..f4f5fe2 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewContentManager.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewContentManager.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTViewManager.h>
 #import <Foundation/Foundation.h>

diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewManager.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewManager.m
index c0ab14d..6177811 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewManager.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXMarkerViewManager.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTViewManager.h>
 #import <Foundation/Foundation.h>

diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXModule.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXModule.m
index 3b0af79..e00b508 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXModule.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXModule.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>

 @interface RCT_EXTERN_MODULE(RNMBXModule, NSObject)

diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXPointAnnotationViewManager.m b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXPointAnnotationViewManager.m
index 6fa19e5..54d0ff9 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXPointAnnotationViewManager.m
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXPointAnnotationViewManager.m
@@ -1,4 +1,4 @@
-#import "React/RCTBridgeModule.h"
+#import <React/RCTBridgeModule.h>
 #import <React/RCTViewManager.h>
 #import <Foundation/Foundation.h>

diff --git a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXStyleValue.swift b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXStyleValue.swift
index 5c74f87..c95fe34 100644
--- a/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXStyleValue.swift
+++ b/node_modules/@rnmapbox/maps/ios/RNMBX/RNMBXStyleValue.swift
@@ -274,7 +274,7 @@ class RNMBXStyleValue {
     }
   }

-  func asExpression(json: [Any]) -> Expression {
+  func asExpression(json: [Any]) -> MapboxMaps.Expression {
     let data = try! JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)
     let decodedExpression = try! JSONDecoder().decode(Expression.self, from: data)
     return decodedExpression
@@ -356,7 +356,7 @@ class RNMBXStyleValue {
     }
   }

-  private func _toExpressions(_ valueObj: Any) throws -> Expression {
+  private func _toExpressions(_ valueObj: Any) throws -> MapboxMaps.Expression {
     if let valueObj = valueObj as? NSNumber {
       throw RNMBXError.parseError("valueObj is a single number and cannot be converted to expressions")
     }
@@ -435,7 +435,7 @@ class RNMBXStyleValue {
     return mglStyleValueEnum()
   }

-  func parseExpression(_ expression: [Any]) throws -> Expression {
+  func parseExpression(_ expression: [Any]) throws -> MapboxMaps.Expression {
     let data = try JSONSerialization.data(withJSONObject: expression, options: .prettyPrinted)
     let decodedExpression = try JSONDecoder().decode(Expression.self, from: data)
     return decodedExpression