mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

SwiftUI

Open vasquezdennisalon opened this issue 6 years ago • 8 comments

how to implement navigation in swiftUi?

vasquezdennisalon avatar Nov 05 '19 22:11 vasquezdennisalon

Anyone? A tutorial would be nice on this. So far it seems you cant even install this currently because it requires a different version of MapboxMobileEvents than what MapboxSDK needs.

CodyPChristian avatar Jan 07 '20 03:01 CodyPChristian

A tutorial would be nice on this.

There’s no tutorial yet for adding the navigation SDK into a SwiftUI application, but this is good feedback for our documentation team. In case it helps, the main entry point for the navigation SDK is NavigationViewController, so you can get up and running as long as you find a way to embed a view controller in your UI.

Note that there’s a known issue with SwiftUI causing a crash in some cases: #2300.

So far it seems you cant even install this currently because it requires a different version of MapboxMobileEvents than what MapboxSDK needs.

This was #2299, which is now fixed as of v0.37.1, v0.38.2, and v1.0.0-alpha.1. If you’re getting an error from CocoaPods or Carthage about a conflicting MapboxMobileEvents dependency, you may need to modify your Podfile or Cartfile:

  • Navigation SDK v0.37.x and v0.38.x require map SDK v5.5.x.
  • Navigation SDK v1.0.0-alpha.1 requires map SDK v5.6.x.

/cc @mapbox/docs

1ec5 avatar Jan 14 '20 18:01 1ec5

I'm struggling with this problem. I don't understand how is possible to keep the navigation controller alive while the app is showing other views.

ghost avatar Feb 26 '20 11:02 ghost

You will need to create a SwiftUI View that represents NavigationViewController. Then you can call .sheet to open a modal (or open a new view) for the navigation. I did play a bit with it when investigating some map solutions for my company's mobile app. Just write a quick tutorial to show how to bring Mapbox navigation to iOS with SwiftUI.

tudatn avatar Apr 25 '20 23:04 tudatn

Two years later and still no SwiftUI documentation? For any new app this would be the default.

danielnordh avatar Jan 27 '22 12:01 danielnordh

@danielnordh Completely agree. I have been struggling to use the SDK for the last two weeks and the lack of up to date guides or tutorials is ridiculous. It seems that almost all major SDK's have support for SwiftUI or even guides made by others, but there is simply no support for this and it is encouraging me to quit on using this SDK. If I figure it out, I will be sure to post my project in here.

arshmeets avatar Jan 28 '22 23:01 arshmeets

Same here, how is it not here yet?

haydgately avatar Oct 11 '22 15:10 haydgately

I found this example which might be useful for others: https://github.com/mapbox/mapbox-directions-swift/tree/9714ec6451bec68ce7a753b8070a0b5664019a1c/IntegrationWithNavigationSDK/MapboxNavigationSwiftUI

treacher avatar Jul 17 '23 10:07 treacher