SwiftUI
how to implement navigation in swiftUi?
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.
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
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.
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.
Two years later and still no SwiftUI documentation? For any new app this would be the default.
@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.
Same here, how is it not here yet?
I found this example which might be useful for others: https://github.com/mapbox/mapbox-directions-swift/tree/9714ec6451bec68ce7a753b8070a0b5664019a1c/IntegrationWithNavigationSDK/MapboxNavigationSwiftUI