I'm preparing my ionic app for an update in the iOS app store but I'm really stuck at the moment because generating resources using ionic resources doesn't work anymore.
After running the command in the terminal it starts uploading the resources I put into the folder, then tells me uploading was sucessfully completed and then freezes completely. Android and iOS folders get created, also the icon and splash folder, but then nothing more happens.
What I tried so far:
- replacing the icon.psd and splash.psd within the resources folder
- resetting the ionic state using ionic state reset (which completely removes the platforms and adds them again) + adding the official icon and splash templates from the ionic website
Versions used:
- Cordova CLI: 5.1.1
- Ionic Version: 1.1.0
- Ionic CLI Version: 1.6.5
- ios-deploy: 5.0.1
- ios-sim: 5.0.1
- Mac OS X Yosemite
- node: 0.12.7
Everything works quite fine on windows for generating android resources.
Can anybody help?
I had similar problems. It has something to do with the way the .png is saved.
Try passing the file through https://tinypng.com/. It has worked for me several times.
I had the same problem and setting the PROXY environment variable solved the issue:
set PROXY=http://<proxyUrl>:<proxyPort>
ionic resources android --icon --force
Hope this helps!
When I had the same challenge with $ ionic resources, I had saved my icon.png and splash.png using the png24 format, when I changed to png8 the command worked and generated the icons and splash screen files, you can give it a try and it could work for you.
you can use offline alternative binary that does the same job without internet plus it supports cross platform
https://github.com/harshzalavadiya/ionic-resource-generator
p.s. i am author of this tiny app
I had similar problems. For fixed:
create new project "ionic start projectX sidemenu"
Copie and paste folder www for new project fodler
Add plugins use in older project
Compile new project
make resources and done!
Related
I'm currently stuck on a problem related to my Ionic project.
I have an Ionic project on GitHub which i've been working on in the past few weeks, i have a few Cordova plugins as part of the project.
When downloading the project from GitHub, i can run the app using Ionic Serve without a problem. However, when trying to setup the project for xCode to run on local device(s), i run into a multitude of errors
Some include:
When running ionic 'cordova platform add ios' the following error appears
Error: Could not install from "ios" as it does not contain a package.json file.
When trying to run 'ionic cordova run ios -l --external'
Error: Error: terminating with uncaught exception of type NSException
I have not yet tried to transfer my code into a new Ionic project, as i wish to see if my problem can be solved without that hassle.
View project code here: https://github.com/designsheikh/bitsandbobs.git
I figured it out. You have the exact same issue I've had with the android platform.
As I pointed it out in the comments, it is indeed caused by a "corrupted" project architecture.
How it happened
Initially, I had an issue with the cordova generated resources, somehow not being copied into the android platform directory. I tried plenty of things with the cordova-res CLI, including using the --copy and the --ios-project flags to force the copy to happen in the directory of my choice.
I couldn't manage to fix my issue, and then decided to rollback all my changes and start over on a clean project to try something else. Since then, I was not able to add the android platform anymore. Every single time, the following error was being thrown :
Error: Could not install from "android" as it does not contain a package.json file.
Explanation
With all my testing, I noticed that when using cordova to add the platform or copy the resources over, somehow, it had created the android platform in the wrong directory, at the root of my project instead of in the platforms folder. And that's where the issue comes from.
I can't explain it, but you will encounter this error every single time if you try to add a platform with cordova while having a folder with this platform name at the root of your project. I have no idea why this would prevent a platform from being added to the project, maybe this folder is used as a temp folder by the CLI.
Solution
The fix is to simply remove any ios or android directory at the root of your project.
The error will go away and you will be able to add the platform again.
#CodingJunkie
Regarding the Github repository you provided in your post, you will likely run into another error while trying to add the ios platform if you use cordova#>=9.0.0.
Using "requireCordovaModule" to load non-cordova module "xcode" is not supported.
Instead, add this module to your dependencies and use regular "require" to load it.
Check this issue#1033 for a workaround. However, it's not recommended to directly edit the plugin source code, you might want to look for another cordova Firebase plugin.
I also noticed you kinda mixed up cordova and capacitor in your project.
Make sure to use one or the other to avoid potential errors.
Hope this helped !
#Reqven
Thank you for your support! - i was sure that i had done this step while trying to fix the issue. It is such an absurd problem, it seems that there is a new project architecture as you mentioned which needs to be followed. I followed your steps with also one minor additional step as im working on the iIOS platform:
Delete iOS folder
cordova platform add ios
cordova prepare ios
ionic build
If step 2 throws an error causing the version not to be found or integrated into the project run - include '#latest' this also solved my problem
Absolutely new to Cordova. These are the steps I've done:
Checked out an existing project
run cordova build ios
The above generates this build error:
(node:10242) UnhandledPromiseRejectionWarning: Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported.)
I've Googled for a solution to the above and the general consensus seems to be to remove and then add the iOS platform.
Now there's a problem with that. Looking through the commit history, I can see that there have been code changes done to files within the platforms directory so I can't just remove it, or...
Question 1)
Can I?
Question 2)
Is it right to make code changes within the platforms directory? Because it seems like those are generated directories.
Question 3)
Why is it that when I open the Xcode project under platforms/ios, I am able to build/run it fine despite the Cordova CLI error above?
it's not right to manually edit the platform files. And some manual changes might make the project not build, so might be related to the manual changes somebody did. So if you don't want to risk to remove the platform, continue building from Xcode
from root www to platforms/ios is transferred by cordova commands such us cordova prepare ios or cordova build ios or cordova run ios.
So if you can't do a cordova prepare ios because of that error you can try a few things.
Copy your files from www to platforms/ios without replacing the whole folder, just the duplicate files. cordova prepare ios is not just a copy, it's also does some modifications/aditions, but if you don't remove existing files it might work.
Create a new project and copy the platforms/ios/cordova to your own project and see if that fixes the mentioned problem, as that's where the Api.js file is.
Downgrade the Cordova CLI, try to latest 7.x.x and if it doesn't work, try with latest 6.x.x, one of those won't require the Api.js as it relatively new.
I am trying to upgrade my Cordova Ionic project ios platform from 3.0.1 to the newest 4.5.2 using xcode 9. I remove the ios platform and re-add it again under CLI 7.1.0. Then I restore all the .xcodeproject settings by copy the old .xcodeproject into the new ios platform and reset all the path necessary in the workspace. Luckily my project build successfully and runs fine in the debug mode.
However when I am trying to upgrade some out of date plugins in the new project, I found that I can only "add" plugin, which everything just goes fine. But when I am trying to remove any plugin (whether they have been added in the new workspace or not), the CLI always show red font message: Error: Could not find *-Info.plist file, or config.xml file.
This message will also show up if I tried to run ionic prepare ios command. Interestingly enough, if I use the .xcodeproject file cordova originally generated, then all the things will just work fine.
Any idea on what specific settings is wrong so that the CLI could only recognize the new .xcodeproject file but not the old .xcodeproject file?
To answer "why don't want to use the new .xcodeproject automatically generated". My project is pretty huge which contains 4 different targets and each of them have different project settings. First of all, CLI don't know that and will only generate one target and I have to duplicate it another 3 times. Secondly, it will be such a pain to restore each target settings one by one. And thirdly the new project doesn't contain any changes in the iOS native code I made such like in appDelegate class. Therefore I just want to find a trick way to make it through.
Cordova creates the files automatically, I believe copying a file generated from an old version and pasting a new one will break your project.
What happens if you remove the platform, add again but without reusing the .xcodeproject? The normal thing is that you got to work normally.
Another option would be to upgrade Cordova or a downgrade, using nvm you can have several versions of Nodejs and Cordova.
You didn't mentioned in your question how you are removing the ios platform , try to do them as follows:
cordova platform remove ios
cordova platform list here you can verify that ios platform deleted
cordova platform add ios --save
I don't know what version you are using but cordova 6.5.0 should solve the ios-build issues. you can install using like below:
sudo npm i -g cordova#6.5.0
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.
I have a strange problem. I develop an app using Ionic on a samba network drive.
I develop on a windows machine and run all the command lines regarding Android development. I switch to a Mac to be able to build for iOS.
All went fine and as expected the last couple of days. Today I edited some HTML, JS and CSS files - just some minor improvements. I built the app for android on the windows machine (plus using jarsigner and zipalign - only if that should matter).
On the Mac I had troubles. Suddenly I get errors when trying to run ionic build --release ios (as I already did successfully the last couple days).
The executed script creates files and folders starting with "._" which were never created before and are already existing without it. This results at some point in an ENOENT (no such file or directory) aborting everything.
I don't get it. I already de-/re-installed node, npm, cordova and ionic. But nothing helped.
I would love to support you guys with additional error messages or logs, but due to I'm fairly new to mobile development (and using a Mac), I don't know what information would be helpful and what not.
Sp please tell me any information you need and I'll be happy to supply them.
I accidentally solved my own problem. I just "removed" the platforms directory (by renaming it) and re-added the platform using the command cordova platform add ios.
After that I could build my app as it did before. Don't know why or what actually triggered this behavior, but at least I'm able to proceed.
If somebody knows how to prevent that from happening again (so that I don't loose all the project settings I configured in Xcode), I would appreciate it.
This happened to me, too - I found this bug in the Cordova issues:
https://issues.apache.org/jira/browse/CB-5644
I found out that Xcode created the file PROJECT_PATH/platforms/ios/._APPNAME.xcodeproject. I deleted this file and "cordova prepared ios" was working again.
...
It should ignore files starting with ._ as they are hidden system
files used by osx to store infos about a file