mapbox / mapbox-maps-flutter

Interactive, thoroughly customizable maps for Flutter powered by Mapbox Maps SDK
https://www.mapbox.com/mobile-maps-sdk
Other
245 stars 93 forks source link

iOS Crash After Migration from mapbox_gl to mapbox_maps_flutter #533

Closed konstantinvoronov closed 1 week ago

konstantinvoronov commented 1 week ago

After migrating from mapbox_gl to mapbox_maps_flutter due to recent Apple privacy manifest requirement updates, the Android version works fine, but the iOS version crashes constantly. Different versions of the plugin yield similar results. Mapbox_gl was using old (MapBox iOS SDK 6.x)

mapbox_maps_flutter Version: 1.1.0 MapBox iOS SDK Version: Latest

if i am using mapbox_map_flutter 1.1.0 with latest MapBox IOS SDK i am getting crash in native code during flutter call to

MapWidget(key: ValueKey("mapWidget"),onMapCreated: onMapCreated);

photo_2024-05-07 08 44 07

The crush happens during factory create in Swift code MapboxMapFactory

var mapInitOptions = MapInitOptions()

or if i updated plugin swift code i would get another error on absolutely ligit call:

      styleURI = StyleURI(rawValue: styleURIString)

if i downgrade back to old 0.5.1 version i end up with early crush at the very app launch. (libdyld.dylib not found, program does not link with libSystem.B.dylib ). when i downgrade i clear cocoapods cache and derrived data, rm podfile.lock and flutter clean, flutter pub get, pod install

konstantinvoronov commented 1 week ago

Solved:

Probably due to the migration, something went wrong in managing different dependencies. I had to ignore CocoaPods and add the Mapbox SDK through Xcode (File -> Add Package). Apparently, adding the package via Xcode instead of pod install is more reliable.

After I added the package to my project using Xcode, flutter run gave me errors like:

Could not build the precompiled application for the device.
Error (Xcode): Multiple commands produce '/Users/konstantinvoronov/AndroidStudioProjects/xxxx/build/ios/Debug-iphoneos/Runner.app/Frameworks/MapboxCommon.framework'

I had to remove the package dependency in Xcode, but something had already gone through, and the project started building normally, fixing the crash.