Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify that arm64 Simulators are not supported for MLKit #1018

Closed
jeancamilo opened this issue Apr 16, 2024 · 23 comments · Fixed by #1226
Closed

Clarify that arm64 Simulators are not supported for MLKit #1018

jeancamilo opened this issue Apr 16, 2024 · 23 comments · Fixed by #1226
Assignees
Labels
Apple Silicon Issues with Apple Silicon bug Something isn't working

Comments

@jeancamilo
Copy link

jeancamilo commented Apr 16, 2024

Hi guys, i'm getting this error every time I try to build for IOS.
Captura de Tela 2024-04-16 às 16 50 11

Can anyone help me how to solve?
Right now, I'm using mobile_scanner 5.0.0-beta.3, because I know the mlkit was update in beta.3.

Flutter doctor

[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4 23E214 darwin-arm64, locale pt-BR)
• Flutter version 3.19.5 on channel stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 300451adae (3 weeks ago), 2024-03-27 21:54:07 -0500
• Engine revision e76c956498
• Dart version 3.3.3
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/jeanlucasdecamillo/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/jeanlucasdecamillo/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/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.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.88.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.86.0

[✓] Connected device (3 available)
• moto e5 (mobile) • ZL5223CQ7G • android-arm • Android 8.0.0 (API 26)
• iPhone SE (3rd generation) (mobile) • A3A102CB-15D1-4CD3-9684-3CF309254045 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.124

[✓] Network resources
• All expected network resources are available.

@navaronbracke
Copy link
Collaborator

The first warning seems unrelated.

However, the second warning indicates that you're unable to build for arm64.
Since you have an ARM Mac, can you confirm that you are either testing on an ARM iOS Simulator or an ARM iOS device?

IIRC MLKit does support ARM and we also don't specify its exclusion in the podspec here https://github.com/juliansteenbakker/mobile_scanner/blob/master/ios/mobile_scanner.podspec

The Simulator is excluded, though, as specified on Cocoapods.org: https://github.com/CocoaPods/Specs/blob/master/Specs/b/5/4/MLKitBarcodeScanning/5.0.0/MLKitBarcodeScanning.podspec.json

Just to be sure, you specified building for the ARM64 architecture in your project settings?

@jeancamilo
Copy link
Author

Thanks for your response @navaronbracke.
I'm trying to embed my application to a native one. So, the time native code try to build using my SDK, it shows me this error and I can't build.
I have these lines in my generated podspec: (maybe add "excluded archs arm64" works?)

s.ios.deployment_target = '12.0'
s.swift_version = '5.0'
s.static_framework = true
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }

Build my Flutter application with mobile_scanner works well, but in this case, building my sdk in a native code, don't. I tried to build from an intel mac but I don't have success too.

@jeancamilo
Copy link
Author

Update:
I added those configs to my podspec:

  s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386 arm64 armv7' }
  s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386 arm64 armv7' }

And the error changed a little, but it persists :(

Captura de Tela 2024-04-22 às 15 52 22

@dgugolf
Copy link

dgugolf commented Jun 4, 2024

I have related issue when try to use different flavors for flutter on iOS, it says Unsupported swift architecture. No idea haw to fix it. So with default scheme it works, but If I make a copy of default one it says error.

@parthpatel-simbiotik
Copy link

I am also facing the same issue in v5.1.1. I am using XCode 15.4. Using MacBook Pro (M1 Pro)
Running on my iPhone 14 Pro Device

Please help how to fix this.

image

@wdcs-vivekmakvana
Copy link

Facing same issue... Any update on this.

@GerlanStanley
Copy link

I have related issue when try to use different flavors for flutter on iOS, it says Unsupported swift architecture. No idea haw to fix it. So with default scheme it works, but If I make a copy of default one it says error.

I had the same problem using flavors

@fulstadev
Copy link

I have related issue when try to use different flavors for flutter on iOS, it says Unsupported swift architecture. No idea haw to fix it. So with default scheme it works, but If I make a copy of default one it says error.

@juliansteenbakker I'm having the same exact problem, and also with the flutter_secure_storage package, also coming from steenbaker.dev.

I could unfortunately reproduce the problem over and over by following the official step-by-step guider for the setup of flutter ios flavors, tried to fix it, but I always get the exact same mentioned error; User-Defined Issue (Xcode): Unsupported Swift architecture, for the two mentioned packages.

I'm wondering if this may be a systematic error somewhere; or if not; do you know why this could happen?

@GerlanStanley
Copy link

GerlanStanley commented Jul 31, 2024

I have related issue when try to use different flavors for flutter on iOS, it says Unsupported swift architecture. No idea haw to fix it. So with default scheme it works, but If I make a copy of default one it says error.

@juliansteenbakker I'm having the same exact problem, and also with the flutter_secure_storage package, also coming from steenbaker.dev.

I could unfortunately reproduce the problem over and over by following the official step-by-step guider for the setup of flutter ios flavors, tried to fix it, but I always get the exact same mentioned error; User-Defined Issue (Xcode): Unsupported Swift architecture, for the two mentioned packages.

I'm wondering if this may be a systematic error somewhere; or if not; do you know why this could happen?

For me what solved it was adding these lines to the Podfile:

post_install do |installer|
      # ADD THIS
      installer.pods_project.build_configurations.each do |config|
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
      ...

@navaronbracke
Copy link
Collaborator

@GerlanStanley That workaround seems to align with the fact that arm64 is not supported, I wonder if we can make it supported (as on M1 Macs the simulators would be arm64)

@fulstadev
Copy link

But don't all of the current iOS devices use the arm64 architecture, isn't that rather modern and excluding it could be risky? Or am I completely wrong here?

@navaronbracke
Copy link
Collaborator

This is talking about arm64 iOS Simulators, not real devices. Presumably this is an issue that occurs only when developing on M1 Macs.

@fulstadev
Copy link

fulstadev commented Aug 1, 2024

Okay I was worried that these things may not be explicitly separated from each other, as e.g. configuring the architecture for android releases in your gradle configs does not make that differentiation AFAIK. But FYI, I'm having the issue too and I'm developing on an M2 Mac, MacOS Sonoma 14.5, with the latest version of XCode (15.4) the latest stable release of Flutter, with an output of flutter doctor showing that everything's fine.

@fulstadev
Copy link

fulstadev commented Aug 5, 2024

installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end

just FYI, this did not work for me. I instead had to add it explicitly to the build settings of every target, using the following in my Podfile, then it worked:

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

    target.build_configurations.each do |config|

          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"

        end
  end
end

@navaronbracke
Copy link
Collaborator

Since this is specifically for arm64 iOS Simulators (I don't know if the reports of this bug also happen with Intel Macs),
I think what we can do is check if we are running on the iOS Simulator, and do:

  1. A conditional import of MLKit
  2. An early return with an "unsupported" mobile scanner error, since Simulators do not have a camera anyway

@navaronbracke navaronbracke changed the title Unable to build for IOS Building for iOS arm64 Simulator does not work Aug 5, 2024
@GeceGibi
Copy link

Any changes ?

@navaronbracke
Copy link
Collaborator

navaronbracke commented Oct 14, 2024

We updated MLKit to version 7.0.0 in mobile_scanner 6.0.0. If that upgrade didn't help, then I do not have any updates.

@antoinepemeja
Copy link

same issue encountered with mobile_scanner: ^6.0.1

User-Defined Issue (Xcode): Unsupported Swift architecture

Had to modify podfile to exclude ARM64 as explain there #1018 (comment)

@navaronbracke
Copy link
Collaborator

It seems that this issue is listed in the MLKit "Known Issues", which I previously missed.

https://developers.google.com/ml-kit/known-issues#ios_issues

Simulators on M1-based Mac are not supported.

I'll add the arm64 simulator to our excluded archs as well, which should fix this issue.
I'll also add a documentation update for this.

@navaronbracke navaronbracke changed the title Building for iOS arm64 Simulator does not work Clarify that arm64 Simulators are not supported for MLKit Oct 23, 2024
@navaronbracke
Copy link
Collaborator

This should be fixed in version 6.0.2

@navaronbracke
Copy link
Collaborator

For anyone wanting to follow along with adding back support for arm64 Simulators, see #1225

@vietanhdtd
Copy link

I upgrade to version 6.0.2 and still can not run in simulator. Real device start normally.

mobile_scanner: ^6.0.2

Issue:


User-Defined Issue (Xcode): Unsupported Swift architecture

Apple silicon M2
Flutter version 3.27.1
Dart version 3.6.0
CocoaPods version 1.15.2
Xcode 15.4

Has anyone try 6.0.2 version and still happen error?

@navaronbracke
Copy link
Collaborator

Version 6.0.2 does not support arm64 iOS Simulators, as that version still uses MLKit for iOS.

You should switch to one of the version 7.0.0 betas, which restore support for the arm64 simulator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apple Silicon Issues with Apple Silicon bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants