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

bug: Barcode-Scanner: Ionic apps using this package wont build for simulators in Xcode on arm64 Architecture (Macs with m-Series CPUS) #99

Closed
4 of 10 tasks
timmkuehle opened this issue Nov 20, 2023 · 3 comments

Comments

@timmkuehle
Copy link

Plugin(s)

  • Barcode Scanning
  • Face Detection
  • Face Mesh Detection
  • Selfie Segmentation
  • Translation

Did you test the latest version?

  • I use the latest version

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

Ionic apps fail to build for simulator in Xcode on Macs using Apples new m-Series CPUs if its incorporating (@capacitor-mlkit/barcode-scanning). (Only tested with macOS Sonoma and Xcode 15)

After implementing the barcode scanner plugin (@capacitor-mlkit/barcode-scanning) and running npx cap sync, the Build Setting Excluded Architectures in Xcode is set to arm64 for Any iOS Simulator SDK automatically (see Screenshot).

SeetingsSetByPlugin

Since newer Macs are running on this architecture and also try to build for an arm64 simulator, the build process fails, providing this error message:
/Users/timmoritzkuehle/Sirum Code/SirumApp_cap5/Code/ios/App/App/AppDelegate.swift:2:8 Could not find module 'Capacitor' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: /Users/timmoritzkuehle/Library/Developer/Xcode/DerivedData/App-ednjbqvwcfwlcbgrebswvcdqcmqf/Build/Products/Debug-iphonesimulator/Capacitor/Capacitor.framework/Modules/Capacitor.swiftmodule

ErrorMessage

By turning the build setting Build For Active Architecture Only you get two different error messages:
Framework 'Pods_App' not found and Linker command failed with exit code 1 (use -v to see invocation)

ErrorMessageWithoutExludedArchs

Currently the only workaround is to run a simulator using apples Rosetta translation layer. This harms performance and introduces a whole new layer potential system related build errors.

Expected behavior

It would be great if barcode scanning would support arm64 architectures natively.

Reproduction

https://github.com/timmkuehle/capacitor-mlkit-barcode-scanning-test

Steps to reproduce

On a Mac with an m-Series CPU:

  1. Create a new ionic project ìonic start
  2. Add the ios folder ``ìonic cap add ios```
  3. Open it in Xcode, start the Simulator and see the build succeed
  4. Implement (@capacitor-mlkit/barcode-scanning)
  5. Sync new modules npx cap sync
  6. Open the app in Xcode again
  7. Notice the new setting for Excluded Architectures mentioned above
  8. Try to run the simulator again and see the build fail

Other information

@AntonGrafton reported this problem in #85. However, it seems that the discussion on that one never got down to the point, where the system architecture was discovered to be causing the issue.

Google has a guide on migrating their MLKit pods for iOS to arm64 Systems. You can find it here. Sadly my pitiful knowledge about capacitor plugin development won't even suffice to tell if this is helpful or not. Sorry for that. 😅

Capacitor doctor

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 5.5.1
@capacitor/core: 5.5.1
@capacitor/android: 5.5.1
@capacitor/ios: 5.5.1

Installed Dependencies:

@capacitor/cli: 5.5.1
@capacitor/core: 5.5.1
@capacitor/android: 5.5.1
@capacitor/ios: 5.5.1

[success] iOS looking great! 👌
[success] Android looking great! 👌

Before submitting

  • I understand that incomplete issues (e.g. without reproduction) are closed.
@timmkuehle timmkuehle added bug/fix Something isn't working needs: triage labels Nov 20, 2023
@robingenz
Copy link
Member

Thank you for your request!

First of all: You can definitely use this project with an M1 Mac and without Rosetta.
Have you tried the fix I mentioned in #85 (comment)? I can't find it in your reproduction.

Google has a guide on migrating their MLKit pods for iOS to arm64 Systems.

We already use the up-to-date ML Kit iOS cocoapods, see:

pod 'GoogleMLKit/BarcodeScanning', '4.0.0'

@timmkuehle
Copy link
Author

timmkuehle commented Nov 20, 2023

Hey. Thanks for your quick reply!

Have you tried the fix I mentioned in #85 (comment)? I can't find it in your reproduction.

This works. Sorry for the oversight! I misread the comment and thought this would fix builds on physical devices only.
Just out of curiosity: Do you know why adding these lines to the Podfile does something different than setting Build For Active Architecture Only to No in Xcode? 🤔

We already use the up-to-date ML Kit iOS cocoapods, see:

Sorry, my knowledge in native capacitor plugin development is so sparse that I couldn't even tell, if the link would be of any help. Just stumbled upon during my research.

PS: Please don't get me wrong. I wanted to be precise and helpful in my PR. Sorry, if I came across a little rude in trying do so so. I really didn't mean to!

@robingenz
Copy link
Member

Just out of curiosity: Do you know why adding these lines to the Podfile does something different than setting Build For Active Architecture Only to No in Xcode? 🤔

You can also do this via XCode, but you have probably configured the App Project and not the Pod Project. This configuration is required by the pods. The code in the pod file ensures that this configuration is restored after each pod installation.

Sorry, my knowledge in native capacitor plugin development is so sparse that I couldn't even tell, if the link would be of any help. Just stumbled upon during my research.

No problem at all! I appreciate any interest in my projects. I am closing this issue. Let me know if you have any other questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants