phonegap asset catatlog - need a tutorial - ios

I'm trying to set the splash and icons in ios.
The app is build with cordova cli 3.3
What ever I do I cannot get slash to show my image on ipad - I get either white screen or the default cordova image.
I've upgraded this app from manual build of phonegap 2.9 where the splash seems to be working fine.
On iphone the splash is displayed.
every time I create a app i waste a few hours playing with it until it show how works.
I wish someone could explain to me how they ment for the asset catalog to work, and what is the fastest way to get the icon/splash into the app.
how come there is no tool to simply throw the images in?

The default Cordova splash images are located at www/res/screens. Within that folder there are platform specific folders that allow you to define splash images for each platform.
The name of the image is based in different conventions for each platform and are documented at http://docs.phonegap.com/en/3.3.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens.
I believe Cordova 3 introduced a config.xml file in www. You should enable the splash screen plugin for your device in that file as per the above documentation. The Cordova CLI should copy the appropriate resources to your platform folder when you do a build.
You should also install the Splash Screen plugin using the CLI by following the instructions at http://docs.phonegap.com/en/3.3.0/cordova_splashscreen_splashscreen.md.html#Splashscreen

Related

What are the sizes required for React-Native app icons? [duplicate]

I am making a React Native app. I would like to customize the app icon (meaning the icon that you click on to start the app). I have Googled this, but I keep finding different types of icons that refer to different things. How do I add these types of icons to the app?
iOS Icons
Set AppIcon in Images.xcassets.
Add 9 different size icons:
29pt
29pt*2
29pt*3
40pt*2
40pt*3
57pt
57pt*2
60pt*2
60pt*3.
Images.xcassets will look like this:
Android Icons
Put ic_launcher.png in folders [ProjectDirectory]/android/app/src/main/res/mipmap-*/.
72*72 ic_launcher.png in mipmap-hdpi.
48*48 ic_launcher.png in mipmap-mdpi.
96*96 ic_launcher.png in mipmap-xhdpi.
144*144 ic_launcher.png in mipmap-xxhdpi.
192*192 ic_launcher.png in mipmap-xxxhdpi.
Update 2019 Android
The latest versions of react native also supports round icon. For this particular case, you have two choices:
A. Add round icons:
In each mipmap folder, add additionally to the ic_launcher.png file also a round version called ic_launcher_round.png with the same size.
B. Remove round icons:
Inside yourProjectFolder/android/app/src/main/AndroidManifest.xml remove the line android:roundIcon="#mipmap/ic_launcher_round"and save it.
Otherwhise the build throws an error.
I wrote a generator to automatically generate icons for your react native app from a single icon file. It generates your assets and it also adds them correctly to your ios and android project:
Update (04/09/2019)
We revamped our generator to be up to date with the ecosystem standards. You can now use #bam.tech/react-native-make.
You can install it using: yarn add #bam.tech/react-native-make in the react-native project
To use it react-native set-icon --path <path_to_png> --background <icon_background_color> --platform <android|ios>
And... that's it! Hope it can be useful for others :)
Recommendations:
1024x1024 base image
No transparent background for iOS
An icon which follows adaptive icons guidelines for Android
Here are some improvements over the previous tool: 🥳
No Yeoman dependency, it is now a react-native-cli plugin
No Image Magick dependency
Creates Adaptive icons for Android
Adds missing icons sizes for iOS
I would use a service to scale the icon correctly. http://makeappicon.com/ seems good. Use a image on the larger size as scaling up a smaller image can lead to the larger icons being pixelated. That site will give you sizes for both iOS and Android.
From there its just a matter of setting the icon like you would a regular native app.
https://help.apple.com/xcode/mac/8.0/#/dev10510b1f7
Set icon for Android application
I was able to add an app icon to my react-native android project by following this guy's advice and using Android Asset Studio
Here it is, transcribed in case the link goes dead:
How to upload an Application Icon in React-Native Android
1) Upload your image to Android Asset Studio.
Pick whatever effects you’d like to apply. The tool generates a zip file for you. Click Download .Zip.
2) Unzip the file on your machine. Then drag over the images you want to your /android/app/src/main/res/ folder. Make sure to put each image in the right subfolder mipmap-{hdpi, mdpi, xhdpi, xxhdpi, xxxhdpi}.
3) Do not (as I originally did) naively drag and drop the whole folder over your res folder. As you may be removing your /res/values/{strings,styles}.xml files altogether.
Android Studio has a very handy icon asset wizard called Image Asset Studio (user guide here). It's quite self explainatory, and has a few handy effects and it's built right in:
Screenshot from Android Studio 4.1.3 on Windows 10
Someone made a very easy to use tool just for this task: https://www.npmjs.com/package/app-icon
This simple tool allows you to create a single icon in your react-native project, then create icons of all required sizes from it. It currently works for iOS and Android.
I've used it. Made a 512x512 png and then ran that tool and boom, done. Super easy.
You'll need different sized icons for iOS and Android, like Rockvic said. In addition, I recommend this site for generating different sized icons if anybody is interested. You don't need to download anything and it works perfectly.
https://resizeappicon.com/
Hope it helps.
This is helpful for people struggling to find better site to generate icons and splashscreen
Make App Icon (useful for both android and ios)
APE tools (useful for both android and ios)
Icon set creator (useful for ios only)
Andoid Asset Studio(useful for android only + recommended*)
Steps Android App icons:
Go to this website https://appicon.co/
Add image their and generate icons, it should be downloaded
Unzip the folder
Inside their copy all the folders in AppIcons/android/ (i.e. Folder
names: mipmap-xxxhdpi,mipmap-xxhdpi,mipmap-xhdpi,mipmap-hdpi,mipmap-mdpi)
paste above copied folders into {rootFolder}/android/app/src/main/res/
and replace existing ones
Remove this line from AndroidManifest.xml
(android:roundIcon="#mipmap/ic_launcher_round")
Icons are successfully added
Change IOS App icons:
Go to this website https://appicon.co/
Add image their and generate icons, it should be downloaded
Unzip the folder
Inside their copy all the folders in AppIcons/Assets.xcassets/ (i.e.
AppIcon.appiconset folder)
paste the AppIcon.appiconset folder into
{rootFolder}/ios/{projectname}/Images.xcassets/ and replace existing one
Icons are successfully added
If you're using expo just place an 1024 x 1024 png file in your project and
add an icon property to your app.json i.e. "icon": "./src/assets/icon.png"
https://docs.expo.io/versions/latest/guides/app-icons
For setting the App launch icon for Android Devices in a React-Native project:
Take a high resolution image of your logo and place it inside your project directory. Preferably in [Project-DIR]/android/app/src/main/res/
Open Android Studio and run your React-native project.
In Android Studio's Project window, select the Android view
Right-click the res folder and select New > Image Asset
A "Configure Image Asset" window will open; Locate your high resolution image and place set it as your "Foreground layer".
Set your "Background Layer" if applicable
Click "Next" and continue to finish.
Run your application again to see the new app launch icon.
Official documentation can be found here: https://developer.android.com/studio/write/image-asset-studio
Use this library to make your work easier.
It will automate your Icon generation process
https://www.npmjs.com/package/#bam.tech/react-native-make
Update 2022
Since the Almouro's Answer is no longer maintained
Android and iOS icon
You can now generate icons with one command both for iOS and Android with rounded icon:
npx icon-set-creator create ./path/to/icon.png
I highly recommend using an icon with a size of at least 1024x1024 pixels
Adaptive Android icon
npx icon-set-creator create -b <background> -f <foreground> -A
background - The color (E.g. "#ffffff") or image asset (E.g. "assets/images/christmas-background.png")
foreground - The image asset (E.g. "assets/images/christmas-foreground.png")
I personally use this link to generate my desired icons https://appicon.co/
And for importing inside the application.
For IOS Setup
Click on your project from Xcode ==>
then on the left side you will see your click on that ==>
Now you will see subfile name Images.xcassets click on that ==>
you icons size will be displayed on the right hand window ==>
simply drag and drop the icons which we have generated from https://appicon.co/ ==>
and your IOS ICON SETUP IS DONE.
Moving to Android
We will go to Android ==> app ==> src ==> main ==> res
Here you will various folders named mipmap-hdpi till xxxhdpi ==>
Drag the icons from the specific folder to your project specific folder.
Happy coding!
To import icons on React Native if you want the icons without having the pictures, then react-native-vector-icons would be the best one. You can use it if you don't want to download the icons and use it in your project.
I would like to suggest to use react-native-vector-icons to import icons to your project. As you use vector icons, you don't need to worry much on icon scaling side. While using the package you are able to use all popular icon set such as fontawesome, ionicons etc..
Besides these iconsets you can also bring your own icons too to your react-native project by packing your icons as a ttf file and you can import that ttf directly to both android and ios project. You can utilise the same react-native-vector-icons library to manage those icons
Here is a detailed procedure to setup custom icons
https://medium.com/bam-tech/add-custom-icons-to-your-react-native-application-f039c244386c
You can import react-native-elements and use the font-awesome icons to your react native app
Install
npm install --save react-native-elements
then import that where you want to use icons
import { Icon } from 'react-native-elements'
Use it like
render() {
return(
<Icon
reverse
name='ios-american-football'
type='ionicon'
color='#517fa4'
/>
);
}

Cordova App -> iOS archive validation failed. Icon missing

I'm trying to upload an iOS app I've developed using Cordova, but, when trying to archive I get this error:
What icon is missing and where should it go? (I have prepared a 72x72 px. icon)
PD: If you could tell me what name should it have would be great.
EDIT:
Here's what's inside my icon folder:
If you built your Cordova project with the Cordova CLI, you should have an icons folder inside yourProjectFolder/resources. There you can find several default PNG icons with the Sencha logo on it, all of them have different size and are named accordingly (for example, there is one called Icon~ipad.png which happens to be 72x72 px). I beliebe this is where you whould put your custom icons for them to be packaged with your app.
EDIT 1 : I thought the Sencha build process would have packaged the content of this resources folder (at least the needed icons) to the targeted platforms resources folder under the cordova folder but apparently you've done it right so I guess all you can do now is dig into the cordova folder. You should try : yourProjectFolder/cordova/www/resources/icons (or maybe yourProjectFolder/cordova/www/img) or somewhere inside yourProjectFolder/cordova/platforms/ios (but having little experience with the ios platform using Cordova I can't think of a particular folder).
EDIT 2 : I made some tests and you indeed have to add the icons manually inside each platform folders within your cordova folder. For example, to add icons for an android app, go to cordova/platforms/android/res and add your icon.png file (with the right width and height, specific to the targeted platform) inside each drawable folders. Then launch a build for your targeted platform (cordova build android) et voilà !

iOS App icon and Splash screen aren't updating for PhoneGap Project

I am using PhoneGap 3.4.0 to create an app.
Within my Phonegap project I have added my own custom app icons here:
MyProject/www/res/icon/ios/icon-57-2x.png
MyProject/www/res/icon/ios/icon-57.png
MyProject/www/res/icon/ios/icon-72-2x.png
MyProject/www/res/icon/ios/icon-72.png
And I have added my own custom Splashscreens here:
MyProject/www/res/screen/ios/screen-ipad-landscape-2x.png
MyProject/www/res/screen/ios/screen-ipad-landscape.png
MyProject/www/res/screen/ios/screen-ipad-portrait-2x.png
MyProject/www/res/screen/ios/screen-ipad-portrait.png
MyProject/www/res/screen/ios/screen-iphone-landscape-2x.png
MyProject/www/res/screen/ios/screen-iphone-landscape.png
MyProject/www/res/screen/ios/screen-iphone-portrait-2x.png
MyProject/www/res/screen/ios/screen-iphone-portrait.png
MyProject/www/res/screen/ios/screen-iphone-portrait-568h-2x.png
I then run this via command line in the MyProject folder:
phonegap build ios
The app seems to compile correctly and I can open the app in xCode and run it in the iPhone simulator, the problem is that the simulator still shows the Cordova default app icon and splashscreen.
I have also replaced the files in the below directress before and after running phonegap build ios but that doesn't seem to fix it either either.
MyProject/platforms/ios/My Project/Resources/icons/
MyProject/platforms/ios/My Project/Resources/splash/
MyProject/platforms/ios/www/res/icon/ios/
MyProject/platforms/ios/www/res/screen/ios/
I've read over the documantation for Icons and Splash Screens but can't seem to figure out why it's not working for me.
Am I missing a step? Should I be running a different command?
Looks like I was doing everything correctly, however in Xcode, I needed to go to:
Product > Clean
...to clear out any old settings and cache.
I found this answer here -> https://stackoverflow.com/a/18868704/647621

Why PhoneGap always shows default splashscreen image?

I'm testing a sample iOS app now, although I set all new launch images in Xcode (Summary tab of Project Target screen), PhoneGap 3.0 keeps showing its default splashscreen. Why? even when splashscreen is a plugin and not included by default in PhoneGap 3.0 now.
iOS document say about launch images but not splashscreen, and it even strongly recommend us to use a "first screen" similar as launch image, not something like about screen. Are these same?
It's not about cleaning or caching issues at all. The problem is PhoneGap includes all possible launch images in project template by default. These files are under Resources folder and copied to bundle's root folder on build event. Although I properly selected my own launch images in Xcode (Target/Summary screen), default PhoneGap's specific files e.g. Default~iphone.png overridden my files :(
Once issue is identified, you can fix it someway, but I prefer below steps:
Delete all default icons and splashscreen files under /platforms/ios/AppName/icons and /splash folders. You surely don't need these placeholder images.
In Xcode, select Targets/AppName, then tab Build Phases, delete all file names of images in the above step in section Copy Bundle Resources.
Add your own images files for app icon and launch images here.
Edit Info.plist file (file AppName-Info.plist under /platforms/ios/AppName/) to include your images, you will need to use CFBundleIcons and UILaunchImageFile keys. Go to iOS developer site for reference.
Splashscreen and launch image are the same thing.
You probably did everything right but iOS (especially in the simulator) often just doesn't change those things (splashscreen, icon etc.) during development process. Try to delete your app, clean your project (in Xcode: Product -> Clean (shift+cmd+k)) and reinstall your app.

How to use Cordova's splash screen API

I have built an iOS app and set the splash (loading) screens in my .plist file, but when I load the app it still shows Cordova's default loading image (see image below).
I see there is an API for this here but I am unsure how to use it or if this is even what I am after.
I am running Cordova 2.7 (and JQuery mobile if that matters).
Would anyone know how to ammend this?
Have you replaced the images with your own in the Resources/Splash folder in the app ?
(Do so in finder rather then xcode!)
Also remember to 'Clean' your build as xcode has a habit of storing that type of thing.

Resources