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 Scanning plugin failing to build on simulator for fresh Ionic project #148

Closed
5 of 11 tasks
JaapWeijland opened this issue Apr 22, 2024 · 6 comments
Closed
5 of 11 tasks

Comments

@JaapWeijland
Copy link

JaapWeijland commented Apr 22, 2024

Plugin(s)

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

Version

6.0.0

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

When adding the barcode scanning plugin, version 6.0.0, the capacitor ceases to build the app via the command line. Error: SwiftEmitModule normal x86_64 Emitting\ module\ for\ App (in target 'App' from project 'App'). Just before adding this package it all worked just fine.

Expected behavior

To be able to build my Ionic app

Reproduction

https://github.com/JaapWeijland/barcode-scanning-repro

Steps to reproduce

  1. Install @ionic/cli (7.2.0)
  2. Run ionic start and create a blank React app.
  3. Run ionic cap add ios
  4. Run ionic cap run ios
  5. Choose iPhone 15 simulator
  6. Verified the build works!
  7. Run npm i @capacitor-mlkit/barcode-scanning
  8. Run ionic cap sync
  9. Run ionc cap run ios
  10. Choose iPhone 15 simulator
  11. Failed with aforementioned error.

Other information

Apple M1 Pro, Sonoma 14.4.1
Xcode 15.3
Simulator iPhone 15
Cocoapods 1.15.2, which pod: /opt/homebrew/bin/pod (so its installed with homebrew)
ionic --version: 7.2.0
ionic cap --version: 7.2.0 (not sure if this matters)

Using capacitor v6

Note: when I run the app via Xcode choosing a simulator with rosetta active, it works. However, I can't choose these rosetta simulators in the list ionic cap run ios provides me.

Capacitor doctor

[success] iOS looking great! 👌

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
@JaapWeijland JaapWeijland added bug/fix Something isn't working needs: triage labels Apr 22, 2024
@JaapWeijland JaapWeijland changed the title bug: Barcode Scanning plugin failing to build on fresh Ionic project bug: Barcode Scanning plugin failing to build on simulator for fresh Ionic project Apr 23, 2024
@JaapWeijland
Copy link
Author

JaapWeijland commented Apr 23, 2024

So I found how I can fix this by altering the ionic cap ios run command of capacitor. In node_modules, in the file @capacitor/cli/dist/ios/run.js, change the line that says id=${target.id} to id=${target.id},arch=x86_64. This will force capacitor to build the project using Rosetta, which is needed to build a project using this plugin for a simulator.

I'm not sure if this is a problem with this plugin, or a missing feature of capacitor to allow for building using Rosetta, especially now that this option to do this as a configuration within Xcode has been removed by Apple.

@robingenz
Copy link
Member

@JaapWeijland
Copy link
Author

JaapWeijland commented Apr 23, 2024

Thanks for your response. I already tried this, and unfortunately, it does not work. I added the lines to the reproduction repo as well, so you can see what I did and try it out yourself if you want.

Edit: actually, I tried running the demo app, but that app errors out with the same error as well:

SwiftEmitModule normal x86_64 Emitting\ module\ for\ App (in target 'App' from project 'App')

Repro path:

  1. Clone project
  2. ionic cap sync
  3. ionic cap ios run

Added Ionic versions to opening post:
ionic --version: 7.2.0
ionic cap --version: 7.2.0 (not sure if this matters)

@robingenz
Copy link
Member

Okay, now I was able to reproduce your problem. But only in the simulator, on a device it works without problems.
This is how i fixed it: robingenz/capacitor-mlkit-plugin-demo@febf323

@JaapWeijland
Copy link
Author

Works! Thanks alot. Since from now on all newcomers will pretty much experience what I've experienced when they want to run their app on a simulator, it might be handy to add this to the documentation or FAQ or something similar. Anyway, thank you very much for helping out!

@robingenz
Copy link
Member

I'm glad that it is now working. I have updated the blog post.

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