Wherever you open it, include a new block inside the dictionary that looks like this: Otherwise you get the row layout which is good for an overview but makes adding these keys more complicated. Tip: If you want to edit the file directly in Xcode, right click it and select Open as and then Source Code. You can open that file either from Xcode or your preferred IDE. Once you have your icons inside Xcode, we also need to reference them inside the ist of your project. That’s only necessary for your main app icon these alternative icons just need to be available in the highest resolution and iOS will handle the rest. You can use the standard 1024×1024 icons here, no need to generate all the different sizes with the Cordova command again. Once you’ve done this, you can simply drag your previously created icons onto that folder and select to copy them into it like in the image below. Inside your project, expand the topmost App element, click on the app folder below it and select New Group. We can achieve this by first adding a new folder inside Xcode, so go ahead and open it by running: npx cap open ios To use alternative icons we need to let our iOS app know about them and include them in the native app bundle. By skipping the config we tell the tool to not write to a config.xml which is only available in Cordova projects. We are not interested in creating the splash screen right now so we use the type icon. # Create only icons within a Capacitor projectĬordova-res ios -skip-config -copy -type icon Now all you need to do is place one of your created icons inside a resources folder at the root of your Ionic app, then install the package globally if you haven’t and run the according command to generate icons for iOS: # If not yet installed Sounds like a Cordova plugin but works fine for Capacitor! To generate the icons ( and optional splashscreens) for your Capacitor application, you can now use the cordova-res package as well. You should have at least two because one of them will be the default icon of our app. Npm install we need some icons to test this functionality, go ahead and create icons with your favourite image editing tool (I usually use Canva to easily create images) and use the size 1024×1024. Once the app is ready we can add our iOS platform and then install the App icon plugin: ionic start capacitorIcon blank -type=angular -capacitor Now we begin by creating a blank new Ionic application with Capacitor enabled. If you haven’t used Ionic before, now is the time to set up your environment and install the Ionic CLI. However, since Capacitor treats native projects as part of your project’s code which is also checked in to source control, you can easily apply any kind of changes to your native projects to enable native functionalities. To change your icon you need to apply changes to your native iOS project, which was always challenging with Cordova and required some magic to make it work ( free frustration included). In this tutorial we will implement the functionality to switch your app icon on iOS using one of the Capacitor community plugins, created by John Borges, a member of our community! You have heard that Capacitor makes it easy to access native device functionality with a simplified API - but does it really work for core native functionalities like changing the app icon on your home screen? Simon also created the Practical Ionic book, a guide to building real world Ionic applications with Capacitor and Firebase. Usage: print(": '\( is a guest post from Simon Grimm, Ionic Insider and educator at the Ionic Academy. do here nothing for 'computed properties' While CFBundleDisplayName is optional in ist files, CFBundleName actually isn't, but if you forget to add it, nothing will break in your system, so you have a corrupt info dict, yet most users will probably never notice and in that case the code most answers may not return anything meaningful at all.įunc stripFileExtension ( _ filename: String ) -> String Most answers just directly access the info dictionary but info dictionaries can be localized by string files and when accessing them directly, this localization is also ignored and thus again a wrong name may be returned, as Finder will display the localized name. All answers that just return CFBundleName will often not return the name the user expects, as if bundles have a CFBundleDisplayName, then this key is displayed by Finder, system frameworks, and most other apps.
0 Comments
Leave a Reply. |