mapbox-maps-flutter
mapbox-maps-flutter copied to clipboard
Library not loaded on iOS
I am trying to embed a Flutter module in a native iOS app by following Option B - Embed frameworks in Xcode.
I created two empty projects (one iOS app and one Flutter app). I managed to build my iOS frameworks (by running flutter build ios-framework
) and I've embedded them in the native project in Xcode. It worked perfectly 😄
I then added a dependency on mapbox_maps_flutter
to my na Flutter project and generated the frameworks again. Now when I run the native iOS app, I get an error in Xcode console:
dyld[76011]: Library not loaded: @rpath/MapboxCommon.framework/MapboxCommon
Referenced from: <EC49D31C-3E96-3C4A-B4A9-503189E7BBEF> /Users/dumbass/Library/Developer/Xcode/DerivedData/NativeXFlutter-hgnhvvxjnufjnmawpvamreicccpm/Build/Products/Debug-iphonesimulator/mapbox_maps_flutter.framework/mapbox_maps_flutter
Reason: tried: '/Users/dumbass/Library/Developer/Xcode/DerivedData/NativeXFlutter-hgnhvvxjnufjnmawpvamreicccpm/Build/Products/Debug-iphonesimulator/MapboxCommon.framework/MapboxCommon' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/MapboxCommon.framework/MapboxCommon' (no such file), '/usr/lib/swift/MapboxCommon.framework/MapboxCommon' (no such file, not in dyld cache), '/Users/dumbass/Library/Developer/CoreSimulator/Devices/BC8A49E8-826E-4AD4-A33E-284F5FBB25FE/data/Containers/Bundle/Application/DEEA242F-FD06-443C-9C88-AB6007127CC6/NativeXFlutter.app/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Users/dumbass/Library/Developer/Xcode/DerivedData/NativeXFlutter-hgnhvvxjnufjnmawpvamreicccpm/Build/Products/Debug-iphonesimulator/mapbox_maps_flutter.framework/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Users/dumbass/Library/Developer/CoreSimulator/Devices/BC8A49E8-826E-4AD4-A33E-284F5FBB25FE/data/Containers/Bundle/Application/DEEA242F-FD06-443C-9C88-AB6007127CC6/NativeXFlutter.app/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Users/dumbass/Library/Developer/CoreSimulator/Devices/BC8A49E8-826E-4AD4-A33E-284F5FBB25FE/data/Containers/Bundle/Application/DEEA242F-FD06-443C-9C88-AB6007127CC6/NativeXFlutter.app/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file)Library not loaded: @rpath/MapboxCommon.framework/MapboxCommon
Referenced from: <2916445A-F516-369B-AA7E-F24C91A3239C> /Users/dumbass/Library/Developer/Xcode/DerivedData/NativeXFlutter-hgnhvvxjnufjnmawpvamreicccpm/Build/Products/Debug-iphonesimulator/MapboxMaps.framework/MapboxMaps
Reason: tried: '/Users/dumbass/Library/Developer/Xcode/DerivedData/NativeXFlutter-hgnhvvxjnufjnmawpvamreicccpm/Build/Products/Debug-iphonesimulator/MapboxCommon.framework/MapboxCommon' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/MapboxCommon.framework/MapboxCommon' (no such file), '/usr/lib/swift/MapboxCommon.framework/MapboxCommon' (no such file, not in dyld cache), '/Users/dumbass/Library/Developer/CoreSimulator/Devices/BC8A49E8-826E-4AD4-A33E-284F5FBB25FE/data/Containers/Bundle/Application/DEEA242F-FD06-443C-9C88-AB6007127CC6/NativeXFlutter.app/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Users/dumbass/Library/Developer/Xcode/DerivedData/NativeXFlutter-hgnhvvxjnufjnmawpvamreicccpm/Build/Products/Debug-iphonesimulator/MapboxMaps.framework/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Users/dumbass/Library/Developer/CoreSimulator/Devices/BC8A49E8-826E-4AD4-A33E-284F5FBB25FE/data/Containers/Bundle/Application/DEEA242F-FD06-443C-9C88-AB6007127CC6/NativeXFlutter.app/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Users/dumbass/Library/Developer/CoreSimulator/Devices/BC8A49E8-826E-4AD4-A33E-284F5FBB25FE/data/Containers/Bundle/Application/DEEA242F-FD06-443C-9C88-AB6007127CC6/NativeXFlutter.app/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/MapboxCommon.framework/MapboxCommon' (no such file)
I managed to track down the issue a little further. The command flutter build ios-framework
for some weird reason doesn't generate all neccessary frameworks. My empty Flutter module project with only the mapbox_maps_flutter depndency added, compiled to ios frameworks, outputs the following frameworks:
- App.xcframework
- Flutter.xcframework
- FlutterPluginRegistrant.xcframework
- mapbox_maps_flutter.xcframework
- MapboxMaps.xcframework
- Turf.xcframework
Here I found that I can downlaod Mapbox SDK that contains the following frameworks:
- MapboxCoreMaps.xcframework
- MapboxMobileEvents.xcframework
- MapboxMaps.xcframework
- MapboxCommon.xcframework
- Turf.xcframework
So what I think is going on, is that the Mapbox Maps SDK isn't being downloaded properly during flutter build phase, but I have no idea why.
I have added the following 3 missing frameworks from the Mapbox website to my Xcode project and it worked!!!!!!
- MapboxCoreMaps.xcframework
- MapboxMobileEvents.xcframework
- MapboxCommon.xcframework
Any idea on what's going on? I actually don't know what I am doing, but would be great if someone with native iOS experience would have a look at this.
Sure it is downloaded properly?
I get below error on trying to build:
` -> Installing MapboxCommon (23.5.0) > Http download $ /usr/bin/curl -f -L -o /var/folders/y2/4x76yp_x4y79vgt87tcphxj80000gn/T/d20231116-92428-rujdj1/file.zip https://api.mapbox.com/downloads/v2/mapbox-common/releases/ios/packages/23.5.0/MapboxCommon.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.14.2 cocoapods-downloader/2.0'
[!] Error installing MapboxCommon
[!] /usr/bin/curl -f -L -o /var/folders/y2/4x76yp_x4y79vgt87tcphxj80000gn/T/d20231116-92428-rujdj1/file.zip https://api.mapbox.com/downloads/v2/mapbox-common/releases/ios/packages/23.5.0/MapboxCommon.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods/1.14.2 cocoapods-downloader/2.0'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
`
curl: (22) The requested URL returned error: 401
@cpuell what do you do to get this output?
@cpuell what do you do to get this output?
My bad,.. i think this is probably due to missing authentication with below instructions:
https://docs.mapbox.com/ios/maps/guides/install/
@cpuell what do you do to get this output?
My bad,.. i think this is probably due to missing authentication with below instructions:
https://docs.mapbox.com/ios/maps/guides/install/
did you manage to solve this?
@cpuell what do you do to get this output?
My bad,.. i think this is probably due to missing authentication with below instructions: https://docs.mapbox.com/ios/maps/guides/install/
did you manage to solve this?
did you manage to solve this?
Can someone please have a look at this issue?
bump
check this https://github.com/mapbox/mapbox-gl-native/issues/16581#issue-790366334