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
709 stars 428 forks source link

[IOS]: Pods/MLImage/Frameworks/MLImage.framework/MLImage' for architecture arm64 #585

Open songhee24 opened 1 year ago

songhee24 commented 1 year ago

when i start building ios project I get an error:

↳
    ** BUILD FAILED **

Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/rn/r4vcnfnn7zj7gwx5w7fbgldh0000gn/T/flutter_tools.K8VYGY/flutter_ios_build_temp_diroPUaJI/temporary_xcresult_bundle

    ld: warning: ignoring file /Users/mac/WebstormProjects/srs/build/ios/Debug-iphonesimulator/Pods_Runner.framework/Pods_Runner, building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64
    ld: in /Users/mac/WebstormProjects/srs/ios/Pods/MLImage/Frameworks/MLImage.framework/MLImage(GMLImage.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/mac/WebstormProjects/srs/ios/Pods/MLImage/Frameworks/MLImage.framework/MLImage' for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Building targets in dependency order
    note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
    note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')

    Result bundle written to path:
        /var/folders/rn/r4vcnfnn7zj7gwx5w7fbgldh0000gn/T/flutter_tools.K8VYGY/flutter_ios_build_temp_diroPUaJI/temporary_xcresult_bundle

Error (Xcode): In /Users/mac/WebstormProjects/srs/ios/Pods/MLImage/Frameworks/MLImage.framework/MLImage(GMLImage.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/mac/WebstormProjects/srs/ios/Pods/MLImage/Frameworks/MLImage.framework/MLImage' for architecture arm64

Could not build the application for the simulator.
Error launching application on iPhone 14.

I tried changing the Excluded Architectures to arm64

Screenshot 2023-04-10 at 18 11 14

the project is being built, but I noticed that after it was built, the simulator slows down very seriously, just the usual scroll lags how can i fix this ? what could be the problem with this ?

but when I uploaded it to the testflight and downloaded and checked there are no lags, does it mean that something is wrong with my laptop?

EDITED:

i tried to create a new flutter app which just builds a list no extra loads

Screenshot 2023-04-11 at 18 41 06

I also tried to change the launch runner to arm64

the same thing, it works slowly, it lags when I try to scroll, as I understand it, this is not related to the library mobile_scanner

but why it throws error when i try to run my app without Excluded Architectures to arm64

Deleting pods or flutter clean doesn't change anything

theDeji commented 1 year ago

I'm having this same issue, please has a fix been found ? changed mine from armv7 to arm64 and it still threw that error

songhee24 commented 1 year ago

@theDeji aggressively trying to understand the problem 😅

theDeji commented 1 year ago

😂 😂 😂 I really do need it fixed

lucasvini382 commented 11 months ago

I try run my app using rosseta but my application broke too.

songhee24 commented 11 months ago

@lucasvini382 hey did you try to put arm64 in Excluded Architectures ?

lucasvini382 commented 11 months ago

Yes @songhee24 i make this

Tienisto commented 9 months ago

If I exclude arm64, then the app does not run at all... I guess it is because I am using an ARM based macOS

mrRedSun commented 9 months ago

Anyone found workaround for this?

Tienisto commented 9 months ago

I figured out that I need to install Rosetta 2.

themon303 commented 6 months ago

This is Known issues for GoogleMlkit.

rdesimone commented 6 months ago

Did somebody figure out how to temporarily remove/disable Google/MLKit to allow developing with simulators for features where mobile_scanner will not be used?

mrRedSun commented 6 months ago

XCode 15 + Sonoma + latest flutter (3.13.6) + default excluded architectures in xcode = simulator working for me on M1 mac

rdesimone commented 6 months ago

@mrRedSun would you mind to share a screenshot of the mentioned xCode Build Settings? Thanks!

mrRedSun commented 6 months ago

@rdesimone sure thing

image
rdesimone commented 6 months ago

Thanks a lot, I removed i386 and now it works!

mrRedSun commented 6 months ago

So the workaround is to remove i386 and the issue disappears. No sure if we can close the ticket yet, but nice to know

rdesimone commented 6 months ago

it was the only difference I could see between yours and my settings.

Hilbert2048 commented 6 months ago

I have the same issue, when introducing mobile scanner package, my App is very slow in iOS simulator...

AnthonyWharton commented 2 months ago

Hi all,

I am working on a completely separate project with XCode but have found a workaround for getting this working on simulators on Apple Silicon Macs. You need to run the project built for x86_64 for simulator builds, and then run the simulator in Rosetta. Until Google fix the known issue linked by @themon303 there is no getting around this.

1) Set up the architecture for your project (not the individual target!), and the Pods project (not a target!) to replicate the following:

![image](https://github.com/juliansteenbakker/mobile_scanner/assets/7091722/d4f39e37-f576-4634-a67f-e01765076713)

**Of importance**: `Any iOS Simulator SDK` should be set to x86_64 and on debug you should enable `Build Active Architecture Only`. Also note I am not excluding any architectures, [Apple themselves do not recommend doing this unless absolutely necessary](https://developer.apple.com/documentation/technotes/tn3117-resolving-build-errors-for-apple-silicon).

2) Check that the Pods config file is not intefering and adding an excluded architecture by lookind under Pods -> Targets Support Files -> Pods-[PROJECTNAME] -> Pods-[PROJECTNAME].debug.xcconfig

![image](https://github.com/juliansteenbakker/mobile_scanner/assets/7091722/91bc11fa-5fe3-4186-9b46-17c77338b6bd)

3) Unhide Rosetta by going to Product -> Destination -> Destination Architectures -> Show Both

![image](https://github.com/juliansteenbakker/mobile_scanner/assets/7091722/f0cc0578-ffd6-4aa3-b486-ebe9368a49f0)

4) Select a Rosetta Simulator (e.g. iPhone 15 Pro (Rosetta)), and run! (might be advisable to clean the build folder prior to running but it should work regardless).

Good luck!