Yogesh Bhople
1 min readSep 19, 2017

Alternate App icon for iOS Application

Now we can set the iOS application icon dynamically among declared in info.plist.

This is very useful feature. Consider simple example, your app have free version as well as paid version. Now, once user purchased the application you can change the application icon or you may have your own use case.

In iOS v10.3, Apple introduced new method setAlternateIconName. You can use this method to change the application icon dynamically.

Lets start,

Open your info.plist file as Source Code (Right click the info.plist file > Open as > Source Code). Then, add the correct supportsAlternateIcons and CFBundleIcons xml to the bottom of your plist, just before the final </dict> (see example below).

For example:

  1. icon@2x.png (primary)
  2. icon@3x.png (primary)
  3. freeVersionAppIcon.png (alternate)
  4. paidVersionAppIcon.png (alternate)

Note: While adding icon file name don’t put extension in .plist file. freeVersionAppIcon.png becomes freeVersionAppIcon in .plist file.

<plist version="1.0">
<dict>
...
<key>supportsAlternateIcons</key>
<true/>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>icon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>paidVersionAppIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>paidVersionAppIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>freeVersionAppIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>freeVersionAppIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
</dict>
...
</dict>

Now set the icon using setAlternateIconName this method.

UIApplication.shared.setAlternateIconName("freeVersionAppIcon") { error in
if let error = error {
print(error.localizedDescription)
} else {
print("Success!")
}
}

Also you can check for support,

if supportsAlternateIcons {

}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response