Can I change app icon programmatically

I have two app icons built-in (free and premium), is it possible to replace free icon to premium icon programmatically after in-app purchase is completed successfully?


There is a new solution for this situation.

You can use

setAlternateIconName(_:completionHandler:)

iOS 10.3 is out with xcode 8.3.

10.3+

Update:

Usage is pretty simple, the key is to find out plist usage and note that you can not load assets from xcassets ( at least didnt work for me ). You need to add your icon files to project and prefer 180x180 images for quality.

You need to use "Icon files (iOS 5)", new Icon files does not work.

One last thing, when you change icon on a button click it will popup a Alert window that says 'You have changed the icon for "IcoTest".'

enter image description here

//ViewController.swift
@IBAction func ico1Click(_ sender: Any) {
    if UIApplication.shared.supportsAlternateIcons{
        UIApplication.shared.setAlternateIconName("Icon2", completionHandler: { (error) in
            print(error ?? "")
        })
    }else{
        print("NO NO")
    }
}

//Info.plist
<key>CFBundleIcons</key>
<dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
        <key>Icon1</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>alternater1_180x180</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
        <key>Icon2</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>alternater2_180x180</string>
            </array>
        </dict>
    </dict>
</dict>

No, the icon is specified in the application bundle, which you must not change. If you change it, your app signature will become invalid (not the same checksum) and thus your app won't run anymore.