Chapters

Hide chapters

SwiftUI Cookbook

Live Edition · iOS 16.4 · Swift 5.8.1 · Xcode 14.3.1

Configuring App Icons & Launch Screens in SwiftUI
Written by Team Kodeco

As developers, one of the things we strive for is to create an app that not only works well but also looks good. One of the ways we can achieve this is by customizing our app’s icon and launch screen. In this cookbook entry, you’ll learn how to do just that in your SwiftUI app.

Adding an Icon to a SwiftUI App

When you create a SwiftUI project, Xcode automatically includes a default asset catalog named Assets.xcassets that contains the AppIcon set. If you wish to change the app icon, follow these steps:

Note: If you want to try out this example, you can download an archive containing an example app icon and launch screen here.

  1. In the Project navigator, select Assets.
    Select the asset catalog in the project navigator.
    Select the asset catalog in the project navigator.
  2. Next, select AppIcon.
    Select AppIcon from the menu.
    Select AppIcon from the menu.
  3. Then, select the square 1024-by-1024-pixel space for your iOS app icon.
    Select the slot for your app icon.
    Select the slot for your app icon.
  4. Drag and drop your app icon image into the slot.
    Drag and drop your desired app icon file into the slot.
    Drag and drop your desired app icon file into the slot.

Now build and run, then tap the Home button in the simulator’s device bezel and you should see the updated app icon:

iPhone simulator with the updated icon.
iPhone simulator with the updated icon.

If you change your mind about which icon to use or if Xcode complains about an incorrectly sized file, just drag a new one on top of the one you no longer wish to use. This is the easy part of finding the perfect app icon!

Adding a Launch Screen to a SwiftUI App

To add a launch screen to your app, first drag the image file you want to use for this into your project’s asset catalog. Next, you need to configure a launch screen in your app’s information property list, info.plist:

  1. In Xcode, select your target and go to the Info tab.
    Select the project in Xcode.
    Select the project in Xcode.
    Select the Info tab.
    Select the Info tab.
  2. In the Custom iOS Target Properties section, find the Launch Screen key. Expand this key by clicking on the disclosure indicator. If you don’t see the UILaunchScreen key, you’ll need to add it. Click on the Add button (+), type in UILaunchScreen and press Return.
    Add the UILaunchScreen key to Custom iOS Target Properties.
    Add the UILaunchScreen key to Custom iOS Target Properties.
  3. Once you have the UILaunchScreen key in place, click on the plus button (+) to add additional keys that specify the configuration options for your launch screen. Here you’ll want UIImageName, which Xcode will change to simply Image name. Then add the name of your launch image, which is launch-logo in this example, as the value.
    Add UIImageName under UILaunchScreen and enter your launch screen's filename.
    Add UIImageName under UILaunchScreen and enter your launch screen's filename.

Now build and run your app and you should see the launch screen!

Simulator with launch screen active.
Simulator with launch screen active.

You can define the appearance of your launch screen by specifying a combination of launch screen options from the possible keys in UILaunchScreen. For instance, you might add a UIColorName key to specify a launch background color or UIImageRespectsSafeAreaInsets to say whether the image respects the safe area or extends all the way to the edges of the device screen.

The process above allows you to customize your app’s launch screen. However, keep in mind that the launch screen is not intended to provide an app preview nor an extensive branding opportunity. It’s primarily used to enhance the perception of your app’s responsiveness at launch.

And that’s it! With just a few simple steps, you can change your app’s icon and launch screen to create a more polished look and feel.

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2024 Kodeco Inc.