mapbox / mapbox-maps-flutter

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

iOS 17 Cannot properly build release version #385

Open blk-raffy opened 5 months ago

blk-raffy commented 5 months ago

Description

All started by this error: Could not find module 'MapboxMaps' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator

I've found other closed issue but they were old and not currently working.

Context:

I'm using an M1 chip

Flutter doctor ```bash [✓] Flutter (Channel master, 3.19.0-9.0.pre.206, on macOS 14.3 23D56 darwin-arm64, locale it-IT) • Flutter version 3.19.0-9.0.pre.206 on channel master at /Users/rafaelbenetton/Documents/Core/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e46394178 (8 ore fa), 2024-01-29 01:46:24 -0500 • Engine revision 210ed1dfb8 • Dart version 3.4.0 (build 3.4.0-82.0.dev) • DevTools version 2.31.0 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at /Users/rafaelbenetton/Library/Android/sdk • Platform android-33, build-tools 33.0.2 • Java binary at: /Users/rafaelbenetton/Desktop/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C500b • CocoaPods version 1.14.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.2) • Android Studio at /Users/rafaelbenetton/Desktop/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.85.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.80.0 [✓] Connected device (3 available) • iPad 17.2 (mobile) • 96F06AA2-37BD-4212-9E6E-A6DB4C6601F9 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.3 23D56 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.234 [✓] Network resources • All expected network resources are available. • No issues found! ```

Troubleshooting

Ok so the problem is (i think) this package does not support Apple Silicon chip. Ok the solutions would be searching for xcode.app > "Get info" > and toggle "Open with Rosetta"

photo_2024-01-29_15-23-24 Well, I don't have this toggle so, by opening xcode instead of vscode (I build with vscode yes) and build the project a dialog shows up: photo_2024-01-29_15-23-01

Nice, let's build with Rosetta then! photo_2024-01-29_15-23-08

Hurray, you have a loop.

What I have to do?

nicolamazz commented 5 months ago

Same issue here

evil159 commented 5 months ago

@blk-raffy @nicolamazz What version of the Mapbox Maps Flutter Plugin do you use? I have no issues with it working on MBP with M1 Pro chip. @blk-raffy You flutter version is 3.19.0-9.0.pre.206, does it help if you switch back to the stable flutter version?

blk-raffy commented 5 months ago

@evil159 I've switched the version of flutter hoping it was a solved issue. I've switched to the main branch and there is the issue there too. I think it's a mapbox related issue because I have another app with mapbox-gl (old flutter package) and it works fine.

I'm using the lastest version of mapbox

blk-raffy commented 5 months ago

Update, by doing flutter build ios the build works fine

Screenshot 2024-02-03 alle 11 48 18

But if I start the emulator I get this:

Screenshot 2024-02-03 alle 11 46 24

The problem is xcode or the emulator? (I think xcode only because the builded app won't boot, it's stucked into the splash screen)

JohnDMarsh commented 3 months ago

Had the exact same symptoms mentioned above on my M1 Pro, resolved it locally by following these steps:

Verifying the project's Podfile:

Previously, I had been using the Mapbox GL Flutter package and had updated my project's Podfile to address a past issue for M1 Macs (https://github.com/mapbox/mapbox-gl-native-ios/issues/487#issuecomment-901146551). I had previously updated my build settings to not target arm64, I reverted this change.

Original Configuration:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
end

Reverted to:

post_install do |installer|
  installer.pods_project.targets.each do |target| 
    flutter_additional_ios_build_settings(target)
  end
end

Removing the Mapbox GL package (https://pub.dev/packages/mapbox_gl):

I was unable to run the simulator with the old Mapbox GL package still installed. Since I'm migrating to this package, I chose to remove it from my project:

This resolved the issue for me, I hope this helps!