I've not managed to get this to work either. I've tried a number of combinations according to the documentation (https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-SW14)https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-SW14.
<key>CFBundleAlternateIcons</key>
<dict>
<key>AlternateIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AltIcon</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
let application = UIApplication.shared
if application.supportsAlternateIcons {
if application.alternateIconName == nil {
application.setAlternateIconName("AlternateIcon") { error in
print(String(describing: error))
}
} else {
application.setAlternateIconName(nil, completionHandler: { error in
print(String(describing: error))
})
}
}
All I get is this error which is normally a file read error:
Error Domain=NSCocoaErrorDomain Code=3072 "The operation was cancelled."
I've tried dumping the icon in the main directory of the project and referncing it simply by it's name, using the postfix @2x/@3x etc. and also tried referencing it through an assets catalog name, but nothing seems to work.
By the looks of things (https://twitter.com/stroughtonsmith/status/823988446108774400?ref_src=twsrc%5Etfw) there are additional keys that are needed for the wording to be used when telling the user that the icon is being changed, but there isn't any mention of that anywhere in the documentation that I've seen. The lack of documentation around the missing keys makes me think that maybe this feature isn't ready for release yet?
It also makes me think that this might not be as useful as I first thought e.g you wont be able to simulate what the calendar app is doing by changing the icon every daty to reflect the date, or changing to reflect the current weather. It looks like it might just be for seasonal changes (you see many apps in the app store making updates just to change to a christmas theme for example) or maybe for upgrading from a free version to a paid version. I can see why it's not a free for all at changing out the icons as the home screen could turn into a disco of alternating icons, but maybe this could be fixed with review guidelines?