juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
744 stars 444 forks source link

Unable to build for IOS #1018

Open jeancamilo opened 1 month ago

jeancamilo commented 1 month ago

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 commented 1 month ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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