How To Set Different App Icons and Name Using Xcode Scheme | by Kelvin Tan | Mar, 2022

Unleash the complete potential of Xcode

Photograph by Christian Wiediger on Unsplash

Xcode supplies us the flexibleness to tweak till we meet our wants. Typically, a few of the wants might be extra environments, resembling Staging, Beta, and so forth. With the completely different environments, you most likely will want some indication to inform the variations, such because the app icon and even the app identify.

For instance, as an engineer, you run debug and launch sometimes, and the issue you at all times face is that each debug and launch have the identical app icon and app identify. Typically, you mistakenly thought debug was launch and vice versa.

There’s a higher approach to cope with that by unleashing Xcode’s full potential. There isn’t a must create an extra goal for Staging, Beta, Omega, and so forth. You simply want to grasp that Scheme is a strong instrument made for us by Apple.

Once you create a brand new mission, Xcode robotically generates two varieties of schemes for you, and they’re “Debug” and “Launch.” Moreover, in the event you want extra schemes, you could create them right here as nicely.

Given that you’ve the debug and launch schemes, that is additionally the place you can do one thing like change the API URL based mostly on the scheme with the instance offered beneath. These usually are not actual URLs by the way in which.

baseURL = ""
baseURL = ""

If debug doesn’t sound that engaging, you can even change the naming both by way of its situation or by deleting the scheme and recreating a brand new one.

The method above lets you change the situation. If I modify debug to staging, my situation would then want to vary as nicely.

baseURL = ""

The above method nonetheless exhibits debug, however in actuality, it is really a staging in response to its situation change. The clear method is to create a brand new scheme.

You might simply duplicate on prime of debug or launch. Normally, it’s on prime of debug as you do not really want an extra launch.

After you have duplicated on prime of debug, you could then rename it to staging.

Behind the scene, you will have to vary much more stuff as you’re simply altering the identify exterior of the hood. You have to to vary the situation.

If in case you have an extra product identifier, you will have to vary that as nicely.

Lastly, you will have to create a scheme the place you possibly can run and construct the mission. You may merely go to Handle Scheme > Add button to create a brand new scheme mission.

This final step modifications all construct configurations to staging.

You now have debug, launch, and staging schemes.

Should you run the app, it’s nonetheless exhibiting “Swifty for debug,” “launch,” and “staging.” It might get somewhat complicated. Typically, you don’t know what scheme you’re looking at within the simulator.

Let’s present a special identify for every scheme which is able to assist us to be much less confused.

There are a number of methods to realize this, and I’ll present you my means of doing it. You’ll first want so as to add a Consumer-Outlined Setting known as APP_DISPLAY_NAME. Right here you can set its identify based mostly on the scheme.

Subsequent, you’ll use Data.plist to point out the app identify based mostly on the Consumer-Outlined Setting.

You’ll now have three completely different names based mostly on the scheme. For this to work, it’s essential to just be sure you have completely different product bundle identifiers for every of the schemes. If all of the schemes use the identical product identifier, you’ll solely find yourself with one app quite than three apps.

Lastly, a last contact could be so as to add completely different app icons based mostly on the scheme. You’ll have to add the icon to the AppIcon.

Subsequent, you possibly can duplicate the AppIcon and rename it, as proven beneath:

Contained in the mission, you’ll then use completely different AppIcon based mostly on the scheme.

This would be the last results of your laborious work.

In conclusion, you possibly can decide no matter works greatest to your mission. I’ve seen initiatives with a number of completely different targets as a substitute of counting on the scheme. I’ve even seen a mission utilizing a script to vary the app icon. Once more, no matter works greatest for you.

A minimum of this fashion, I’m utilising Xcode’s full potential by utilizing schemes.

More Posts