Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

ionic cordova local plugin error with new M1 macs

We have a some local plugins which were added using ionic cordova plugin add ./cordova-plugin-name

When building on intel macs they work fine, but in the new M1 mac with Big Sur I get the below error when building the project

Discovered saved plugin "cordova-plugin-ionic-keyboard". Adding it to the project
Installing "cordova-plugin-ionic-keyboard" for ios
Adding cordova-plugin-ionic-keyboard to package.json
Discovered saved plugin "cordova-plugin-iovation". Adding it to the project
Failed to restore plugin "cordova-plugin-iovation" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin file:scripts/plugin/cordova-plugin-iovation via registry. Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR!
Cannot read property 'match' of undefined
npm ERR!
npm ERR!
Discovered saved plugin "cordova-plugin-advanced-http". Adding it to the project
Failed to restore plugin "cordova-plugin-advanced-http" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin file:scripts/plugin/cordova-plugin-advanced-http via re gistry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR!
Cannot read property 'match' of undefined
A complete log of this run can be found in: /Users/xx/.npm/_logs/2021-01-21T12_29_50_477Z-debug.log
npm ERR!
npm ERR!
Discovered saved plugin "call-number". Adding it to the project
Installing "mx.ferreyra.callnumber" for ios
Adding mx.ferreyra.callnumber to package.json
Discovered saved plugin "cordova-plugin-app-version". Adding it
Installing "cordova-plugin-app-version" for ios

Is this a known issue and how can I fix it?

question from:https://stackoverflow.com/questions/65837565/ionic-cordova-local-plugin-error-with-new-m1-macs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It looks like the CLI doesn't understand that these are local plugins and therefore it tries to download them from the registry. This is most likely an npm problem. Something doesn't play nice with cordova and npm 7. I suggest you run node v15.6.0 (latest non lts).

This version normally comes bundled with a newer npm (v7), however for this to work (until cordova sorts their stuff out), you have to downgrade npm to 6.14.11

I have done this with (the use of sudo or not will depend on your environment setup):

sudo npm i -g npm

Or you can specify a version with:

sudo npm i -g npm@version

Source for the above solution: https://github.com/apache/cordova-cli/issues/541

Other than that, I just had to fight for a few hour to get stuff building on my M1...

Some hints that will probably help you out tremendously:

  • Cocoapods needs to be installed in a rosetta mode terminal. You will most likely need to install the ffi gem in that same terminal before installing cocoapods and running pod install inside the ios platform folder. The native ffi gem that is there by default doesn't seem to work with cocoapods.
  • You will have to exclude arm64 and x86_64 architecture emulators from being built automatically in XCode. If you don't you will get symbols missing errors on build.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...