Cordova geofence plugin is not working with Ionic 4 - cordova-plugins

While adding cordova-plugin-geofence I am getting the following error
Cannot find module '../../src/cordova/platform_metadata' Require stack:
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/plugman.js
- /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/cordova-lib.js
- /usr/local/lib/node_modules/cordova/src/help.js
- /usr/local/lib/node_modules/cordova/src/cli.js
- /usr/local/lib/node_modules/cordova/bin/cordova
And also the following error
Failed to install 'cordova-plugin-geofence': CordovaError: Version of installed plugin: "cordova-plugin-add-swift-support#2.0.2" does not
satisfy dependency plugin requirement
"cordova-plugin-add-swift-support#^1.6.0". Try --force to use
installed plugin as dependency. at
/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:544:43

Follow the following steps
cordova platform remove ios
cordova plugin rm cordova-plugin-add-swift-support
cordova plugin add cordova-plugin-add-swift-support#1.6.0
cordova plugin rm cordova-plugin-geofence
cordova plugin add cordova-plugin-geofence
cordova platform add ios
cordova clean
Let me know if its working or not.

Related

Siri implementation in IONIC- Cli 5.4.13 Native

When i install Cordova Plugin cli command some exception get error display in below
Using "requireCordovaModule" to load non-cordova module "glob" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
[ERROR] An error occurred while running subprocess cordova.
How to implementation IONIC Native -Siri
This error sometimes implies that the plugin is not compatible with your project's cordova version. Try downgrading to Cordova 8, I think ionic 5 application comes loaded with Cordova 9. Add cordova dev dependancy as
npm install cordova#8.0.0 --save-dev

Cordova 8 + iOS 4.5.4 = cannot find module "../cordova/platform_metadata"

Since the latest update to v8 of Cordova, I cannot build anything on Mac.
I always get
(node 626) UnhandledPromiseRejectionWarning: Error: Cannot find module '../cordova/platform_metadata'
I tried what was suggested in this post but I get the same error.
I then did a verbose and it seems like the plugin required to build for ios is not working well
Executing script found in plugin cordova-plugin-swift-support for hook "after_prepare": plugins/cordova-plugin-swift-support/src/add-swift-support.js
Resolving module name for cordova-lib/src/cordova/platform_metadata => ../cordova/platform_metadata
(node:599) UnhandledPromiseRejectionWarning: Unhandled promise rejection
(rejection id: 1): Error: Cannot find module '../cordova/platform_metadata'
(node:599) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.
This was a bug in cordova-plugin-add-swift-support, just update it to latest version (1.7.1)
cordova plugin rm cordova-plugin-add-swift-support
cordova plugin add cordova-plugin-add-swift-support
you need to downgrade cordova 7.1.0 until this issue is fixed. Do this:
npm uninstall -g cordova
npm install -g cordova#7.1.0
cordova platform remove ios
cordova platform add ios
If your running an ionic project that requires the swift plugin you'll need to add the --force flag:
ionic cordova plugin rm cordova-plugin-add-swift-support --force
Then run:
ionic cordova plugin add cordova-plugin-add-swift-support
That just happened to me (using Ionic). In Ionic, the issue comes from a plugin or node_module that is still using cordova/platform_metadata, which is deprecated.
If you are using Linux, in your project directory, try this in the command shell:
grep -iRn 'platform_metadata'
In my case, it was the plugin cordova-plugin-add-swift-support that was still using that, and I wasn't even using that plugin my project, so I deleted it manually. Problem solved. The issue seems to arise when a plugin is calling a module that no longer exists, so you have to either remove that plugin or update it.
With Ionic 3 and Cordova 8.0.0 project.
Here are steps
ionic cordova platform remove ios
ionic cordova plugin rm cordova-plugin-add-swift-support
ionic cordova plugin add cordova-plugin-add-swift-support
ionic cordova platform add ios
I have faced same problem, then upgraded Cordova to 7.1.0 work for me
From my ionic project I did (bash):
grep -r 'platform_metadata' .
and found I had a plugin called cordova-plugin-swift-support was the culprit. I removed it and then added cordova-plugin-add-swift-support back in, and everything worked fine with cordova 8.0.0

cordova prepare not add plugins to iOS

I'm building mobile app with Cordova 5.3.3.
I've add plugins with cordova plugin add some.plugin --save and add platform using cordova plugin add ios --save
The problem is if I completely remove rm -rf platform/ios and then run cordova prepare the resulting Xcode proejct does not have anything in the Plugins directory.
The only was I found to solve this is to remove and re-add the plugins but that's seem like the wrong thing to do.
For getting the plugins, you should do it before cordova prepare. Use cordoba platform add iosand it should work

Ionic Platform Add IOS

when I try to add platform ios to my current ionic project the following problem is occurred to me:
Installing "cordova-plugin-whitelist" for ios
Plugin doesn't support this project's cordova-ios version. cordova-ios: 3.9.1, failed version requirement: >=4.0.0-dev
Skipping 'cordova-plugin-whitelist' for ios
How to solve the problem above? What should I do for it?
When I was reading the Ionic docs, I saw a section about Cordova which is called "Cordova Updates". So...when you get an error, a good practice is to search at the official documentation - it might be helpful.
Cordova Updates
$ sudo npm update -g cordova
In your case:
$ cordova platform update ios
Hope it helps.
$ cordova plugin rm cordova-plugin-whitelist
$ cordova plugin add cordova-plugin-whitelist#1.0.0

Error 404: cordova-plugin-file when trying to install cordova-plugin-zip for iOS

When trying to install the cordoba-plugin-zip using:
cordova plugin add https://github.com/MobileChromeApps/zip.git
as documented (https://github.com/MobileChromeApps/cordova-plugin-zip),
I get the below 404 error message. Has the cordova-plugin-file its trying to reference been moved? How can I tell the plugin to look for it elsewhere if so?
Installing "cordova-plugin-zip" for ios
Fetching plugin "cordova-plugin-file" via plugin registry
npm http GET http://registry.cordova.io/cordova-plugin-file
npm http 404 http://registry.cordova.io/cordova-plugin-file
Failed to install 'cordova-plugin-zip':Error: 404 Not Found: cordova-plugin-file
This plugin now depends on cordova-plugin-file (which is not available on cordova.io for now because it is an unreleased version of org.apache.cordova.file, see https://issues.apache.org/jira/browse/CB-8806).
So this dependency needs to be installed from its GitHub repository, like this:
cordova plugin add https://github.com/apache/cordova-plugin-file.git
And then you can install cordova-plugin-zip:
cordova plugin add https://github.com/MobileChromeApps/zip.git
Note: if you use any other plugin dependending on org.apache.cordova.file (like org.apache.cordova.file-transfer or org.apache.cordova.media), you will have to replace them with their GitHub repositiories too.
I think the correct thing to do is to only download released versions of the plugin by fetching from the (now obsolete) http://plugins.cordova.io registy, or from npm:
Old registry:
cordova plugin add org.chromium.zip
New registry:
cordova plugin add cordova-plugin-zip
Note that you need cordova v5.0.0 to be able to fetch from the new registry (NPM)
Try this:
cordova plugin add https://github.com/MobileChromeApps/cordova-plugin-zip.git
Or this:
cordova plugin add https://github.com/MobileChromeApps/cordova-plugin-zip

Resources