setAlternateIconName: did anyone manage to make it work?

I'm having issues with the icons not found:


Error Domain=NSCocoaErrorDomain Code=4 "The file doesn’t exist." UserInfo={NSUnderlyingError=0x650000055f90 {Error Domain=LSApplicationWorkspaceErrorDomain Code=-105 "iconName not found in CFBundleAlternateIcons entry" UserInfo={NSLocalizedDescription=iconName not found in CFBundleAlternateIcons entry}}}


Did anyone manage to make it work? Thanks.

Accepted Reply

Wait check this project. He managed to do it

https://github.com/steventroughtonsmith/AlternateIconTest

Replies

1 . add CFBundleAlternateIcons and CFBundlePrimaryIcon to info.plist.

Notice: According to my test,adding CFBundlePrimaryIcon is necessary or icon may mismatch.



<key>CFBundleIcons</key>
<dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
        <key>AppIcon2</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>AppIcon2</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
    </dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
        <key>CFBundleIconFiles</key>
        <array>
            <string>AppIcon60x60</string>
        </array>
    </dict>
</dict>

2 . add AppIcon2@2x.png AppIcon2@3x.png to project(not Assets.xcassets)

According to my test,adding to Assets.xcassets leading to no effect.


You may also try my demo https://github.com/summer-wu/iOS10d3Demo

Just a heads up for my fellow Googlers, I was having trouble implementing this in my app. Using the simulator, iPhones would work, but iPads would not. I was seeing this error:


error: Error Domain=NSCocoaErrorDomain Code=4 "The file doesn't exist." UserInfo={NSUnderlyingError=0x60800044b3a0 {Error Domain=LSApplicationWorkspaceErrorDomain Code=-105 "iconName not found in CFBundleAlternateIcons entry" UserInfo={NSLocalizedDescription=iconName not found in CFBundleAlternateIcons entry}}}


I was referencing these two example repos:


https://github.com/steventroughtonsmith/AlternateIconTest

https://github.com/iSame7/AlternateAppIcons


I tried a bunch of debugging stuff and finally hit upon something that seems to help. I noticed if I replaced the contents of my "AppIcon.appiconset/Contents.json" file with one from the example repos, things seem to work on the iPad. I'm not 100% sure what's going wrong, but my Contents.json specifies a "filename" and I suspect that's the root of the problem.


Hopefully this helps future frustrated developers. Thanks!

I was facing the same problem. iPhone work, iPad doesn't.

Then I saw the documentation that was posted here.


Here's the link again:

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-SW14


There's a *Important* area that coments about the iPad.

It seems that iPad does not care about "CFBundleIcons", it reads from "CFBundleIcons~ipad" variant and we have to include the files again.


Doing that solved for me.