Ionic Platform Add IOS - 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

Related

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

The plugin command has been renamed

After installing Ionic last version 3.1.2 I tried to add the Native Geolocation plugin and I got the following:
ionic plugin add cordova-plugin-geolocation
The plugin command has been renamed. To find out more, run:
ionic cordova plugin --help
I will appreciate any help on this.
Thanks in advance
According to the docs, the command for ionic cli version 3 is:
ionic cordova plugin add cordova-plugin-geolocation

IONIC:Unable to install phonegap-plugin-push in ios app

I am new with ionic framework.Currently i am working on ionic iOS app. when i install phonegap-plugin-push i am getting error
Failed to install 'phonegap-plugin-push':undefined Error: /Library/Ruby/Gems/2.0.0/gems/claide-1.0.1/lib/claide/command.rb:439:in `help!': [!] You cannot run CocoaPods as root. (CLAide::Help)
i have searched it but no solution found yet!
I also got same kind of problem. In my case I used sudo ionic platform add ios
This is worked well while building every plugins but phonegap-plugin-push.
phonegap-plugin-push is keep giving above error [!] You cannot run CocoaPods as root. (CLAide::Help)
Then I used ionic platform add ios without sudo This is the actual solution for this. But in this case It is keep giving me the permission related issue code EACCESS.
Then I used followings step to overcome that one.
sudo chown -R $USER /usr/local/
Again added cordoava and ionic
sudo npm install -g cordova
sudo npm install -g ionic
Other informations
phonegap-plugin-push version: 1.10.0
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.2
Node Version: v7.7.2
Xocde Version: Xcode 8.2.1
CocoaPods Version: 1.2.0
Hope this will help.

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.

Nothing at all happens when running cordova prepare ios

I am in a ionic app at its root folder. I have a config.xml file and am having trouble getting it to build. I had no issues a few weeks ago, but I've screwed something up on my system I think. I have reinstalled both cordova and ionic and re-pulled the repo.
However, when I run ionic prepare ios --verbose literally nothing happens.
This is the only output:
ConfigXml.setConfigXml /Users/ben/code/project/app resetContent=true, errorWhenNotFound=false
ANY guidance as to what I should try next is very much appreciated.
cordova version is 5.2.0
npm version is 3.3.12
node version is v5.4.1
ionic version is 1.7.14
cordova platform ls outputs:
Installed platforms: ios 3.9.1
Available platforms: amazon-fireos, android, blackberry10, browser, firefoxos, webos
As mentioned in this thread on Github, there is an issue in Node v5 that makes ionic prepare fail.
In order to solve it you can try a couple of things.
One would be to update your cordova installation to version 5.4 or later, since it includes a fix for the Node v5 problem. You can do that using following code:
npm install -g cordova
The other suggested solution in the link is to reset the state of your ionic installation. Be aware that issuing this command will do following (as specified in Ionic-cli github page):
The ionic state reset method will first remove your platforms and
plugins folders. Then it will look at your package.json file to
re-install the platforms and plugins as specified there.
This command can be helpful for you to reinstall your plugins and
platforms to get a fresh start.
If you are willing to try, you can do it with following command:
ionic state reset
Personally I would try first to upgrade Cordova.
Try:
sudo ionic prepare ios --verbose
Whenever you install new plugins or platforms you must also change the read/write permissions on root folder for your project.

Resources