Cordova not recognizing plugins after updating them - ios

I updated all the plugins I was using in cordova using the remove and add method.
cordova plugin rm org.apache.cordova.device
cordova plugin add org.apache.cordova.device
....
I then prepare and build
cordova prepare ios
cordova build ios
I test the app on the simulator and I get:
ERROR: Plugin 'Device' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml
Why is this happening? I was under the impression that the command line was going to update everything automatically, what am I missing?
Before the rm and add everything was working fine.
Thank you for your time.

If anyone stumbles on this, I found the solution.
After updating, adding or removing plugins, you should always do this:
cordova platform rm ios
cordova platform add ios
That will fix any issue.

Related

"GoogleSignIn/GoogleSignIn.h" file not found

I am using Ionic with the google Plus cordova plugin: https://ionicframework.com/docs/v3/native/google-plus/
I set up everything correctly and it works without any problems on Android.
On iOS I used the command "Ionic cordova prepare iOS", at first I got problems with some Cocoapods ("cannot run cocoapods as root"), I fixed that Error with the help of this post: Can't run sudo pod install after updating to cocoapods 0.32.1 with error "You cannot run CocoaPods as root. (CLAide::Help)". After that I was able to get a .xcodeproj.
After some research I found out I have to open the .xcworkspace.
I clicked on run and got the Error: "GoogleSignIn/GoogleSignIn.h" file not found
Uninstall plugin : cordova plugin rm cordova-plugin-googleplus
Install plugin version 7.0.1: cordova plugin add cordova-plugin-googleplus#7.0.1
This will fix your problem reason being version 7.0.1 doesn't use POD dependencies.
Solution: downgrade cordova-plugin-googleplus to version 7.0.2
If you are using Firebase make sure that your podfile is not written GoogleUtilities, if so delete it, and leave only GooglePlus. Then give
pod install
to the root of your project and that's it.
Accepted the answer from ch3t. However on installing you need to supply the app specific variables as seen below. For reference visit the link https://github.com/EddyVerbruggen/cordova-plugin-googleplus/blob/master/README.md#4-installation-phonegap-cli--cordova-cli
cordova plugin add cordova-plugin-googleplus#7.0.2 --save --variable REVERSED_CLIENT_ID=myreversedclientid --variable WEB_APPLICATION_CLIENT_ID=mywebapplicationclientid
I had encountered with the same problem and solved it by this:
Copy ios/RNGoogleSignin into Libraries folder in Xcode
Add this line to Framework Search Paths in Build Settings:
$(PROJECT_DIR)/GoogleSDK
Remove libRNGoogleSign.a from Link Binary With Libraries in Build
Phases:
And lastly clean your build folder and build.
Credits to: taingmeng
I used an old mac, that was the problem

Ionic Cordova: Is there a way to set fixed cordova-ios version

Currently I am building an Ionic App.
When i clone a fresh copy of my repo and add platform ios, cordova-ios#5.0.1 is used because of following line in config.xml
<engine name="ios" spec="5.0.1" />
But when i remove platform iOS, this line also gets removed.
Therefore, on the next read cordova-ios#4.x.x gets installed. But I need at least version 5.0.1 otherwise the Google Maps plugin wont work.
Can i somehow force the use of cordova-ios#5.0.1?
Tried to find resolutions to the problems and tried various different settings in package.json and config.xml, nothing helps.
When adding the platform again (either in your build-script or manually), try
ionic cordova platform add ios#5.0.1
or
ionic cordova platform add ios#latest
Also the platform version is probably defined in your package.json. Maybe there the old version is set to 4.x.x, which is why it still downloads the older version, when not specifying the version yourself.
My solution right now:
I added 2 items to the scripts part in package.json
"add:ios": "ionic cordova platform add ios#5",
"rm:ios": "ionic cordova platform rm ios"
So the workaround now is to use
npm run add:ios
instead of
ionic cordova platform add ios#5

Error building ios with cordova

I have a problem when I build the ios platform with cordova. I have all the certificates for the app and device, but when I try to run in my ios device, doing ionic run ios, the console return this error:
Error: Source path does not exist: resources/ios/icon/icon-40#3x.png
This path is written in config.xml file.
I tried to run it in xCode but the problem there was:
Cordova/CDVViewController.h not found
I read a lot of possible solutions but any works for me.
My xCode version is 7.3.1, the cordova version is 6.3.0 and the cordova ios version is 4.2.0.
If you are missing the icon you can run the command
ionic resources --icon
This will generate all the icons with the pixels needed to run on any device.
To simulate on the device you first need to
ionic build ios
and then
ionic simulate ios
It is also a good practice to have xcode up to date.
If you are still getting the error you can paste this line
"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include"
on Build Settings > Header Search Paths.
Do not remove the similar line, just add it at the end.
Update - 03-08-2017
> ionic cordova resources
Old CLI command:
I had the same error, and after re-running ionic resources it went away.
The problem was that I had Windows-style slashes (backslashes) in the path of the icon, i.e. the error I had was this:
Error: Source path does not exist: resources\ios\icon\icon-40.png
So, converting backslashes into slashes resolved it for me.
Update:
And regarding your second error, it helped me to reset the state:
ionic state reset
Make sure you have ios listed under cordovaPlatforms in your package.json before running this command. Then ionic automatically re-downloads your plugins afresh and is ready to build.
Hope that helps. Take care!
I've had same error only with other image:
Source path does not exist: resources/ios/icon/icon-40#2x.png
This happened after upgrading to Cordova 6.3.0 and I've solved it downgrading Cordova.
Quickfix for now:
npm uninstall -g cordova
npm install -g cordova#6.2.0
Just use:
Remove platform
cordova platform remove ios
And add ios platform with old one
cordova platform add ios#4.0.0 --save
It worked for me..
#4.0.0 will select previous version automatically
I have try some times, finally success.
use ionic resources --icon , maybe met the new problem
"Unable to generate images due to an error Failed to upload source image: Error: read ECONNRESET"
don't worry , try it later
use ionic platform remove ios
when execute successfully
use ionic platform add ios
DON'T USEionic state reset
Try to replace the "\" with "/" (backslash and slash) in the config.xml.
If you create the project on a Windows system and move to macOS for iOS compilation, it still has the Windows URI format.
I've found this issue in several occasions and some of the provided answers worked quite well till today, when no one worked.
My environment: MacOS high Sierra 10.13, ionic cli 3.18.0 and cordova 7.1.0.
My problem was that if I run ionic cordova prepare it fails saying that I need to add a platform and if a I add a platform with ionic cordova platform add ios it fails with the error specified in the answer:
Error: Source path does not exist: resources/ios/icon/icon-40#3x.png
What solved my issue was manually creating the platforms folder: mkdir platforms. After creating this folder, adding a platform worked as usual.
I hope it could help someone out there.
I got similar issue with cordova-ios#~4.5.1
ionic cordova build ios
> cordova build ios
Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png
[ERROR] An error occurred while running cordova build ios (exit code 1).
ionic cordova platform add ios
> cordova platform add ios --save
Using cordova-fetch for cordova-ios#~4.5.1
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: -
Name: -
iOS project created with cordova-ios#4.5.4
Error: Source path does not exist: resources\android\icon\drawable-xhdpi-icon.png
I remove ios platform
ionic cordova platform remove ios
And add ios platform with old one
ionic cordova platform add ios#4.0.0
This worked for me, waiting for an Cordova update :)
it's a cat and mouse problem,
the icon resources aren't built because the platform isn't added and
platform can't be added because the icon resource isn't there
ionic/cordova is pretty unstable and a nightmare to work with in CI pipeline.
this kept crashing out CI pipeline. just keep removing and adding the android/ios platform and build the resources using ionic cordova resources --force
Running these commands solved it for me:
ionic platform rm ios
ionic resources
ionic platform add ios
I had to manually copy the files from any another project repo
such as https://github.com/sphilee/eTAS_GPS/tree/master/resources/ios
It says that the resources directory only contained empty folders. Downloading this repo (https://github.com/ionic-team/ionic2-app-base/tree/master/resources)
and replace the resources directory
Run again the "ionic cordova resources".
You just need to update the cordova to fix this error: to update the cordova run below command
$sudo npm install -g cordova#6.2.0
once you update the cordova type below command to remove the platform
$sudo ionic cordova platform rm ios --save
And then add platform again using below command
$sudo ionic cordova platform add ios --save
I hope this will help you.
I ran into the same problem:
Error: Source path does not exist: resources/ios/icon/icon-40#3x.png
Looks like the relative path is in reference to the config.xml. If the resources folder exists inside of 'www', then you may need to update the relative path.
I was able to resolve this by updating the relative path to "www/resources/...".
It's likely that your resources haven't been run.
Run:
npm i -g cordova-ionic platform rm ios
ionic platform rm ios // You want to do this just so when you recreate you have necessary resouces
ionic cordova resources
ionic cordova build --release <ios/android>
There should be more answers with this solution, since ionic is a project based on npm and this command will install the necessary libraries.
I used the no brain way, but it works. I added the ressources temporarily with the name they ask for.
Like I copy and past an image icon-20 copy.png then rename it into my needed ressources like icon-small#2x.png
use
ionic cordova resources --icon
if permission required use sudo
sudo ionic cordova resources --icon
it will Generated 28 resources for iOS and Generated 6 resources for Android.
make sure you add:
xmlns:cdv="http://cordova.apache.org/ns/1.0
to the widget section(on the very top) of your config.xml
This will add all necessary Cordova components.

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

Cordova Build Error After Removing And Add The Same Plugin

I am getting build error while I am removing the plugin through Cordova CLI and again add the same plugin. Anybody can help me why I am getting error?
Thanks in Advance :)
Hi myself found the issue. While I am adding plugin to cordova iOS project, required frameworks also getting added to the XCode Project (Frameworks mentioned in plugin.xml). And while I am removing the plugin, the framework already added still remains in the XCode project navigator window. When again I am adding the plugin, cordova not adding the framework to this project hence getting the build error.
Solution
Run Cordova remove plugin through CLI
Manually remove the unused framework reference from the xcode project.
Add the plugin through Cordova CLI
I think this is either a Cordova or XCode bug. This error is inconsistent and its is happening sometimes. I got this error while developing & testing custom Cordova plugin.

Resources