#StackBounty: #ios #iphone #swift #xcode #ipad Changing alternate icon for iPad

Bounty: 150

I have a problem with changing app’s icon on iPad. Everything is working fine on iPhone but on iPad I get this error :

[default] Failed to set preferredIconName to AI-Gorgosaurus for
…:0> error: Error
Domain=NSCocoaErrorDomain Code=4 “The file doesn’t exist.”
UserInfo={NSUnderlyingError=0x600000248a30 {Error
Domain=LSApplicationWorkspaceErrorDomain Code=-105 “iconName not found
in CFBundleAlternateIcons entry”
UserInfo={NSLocalizedDescription=iconName not found in
CFBundleAlternateIcons entry}}} App icon failed to due to The file
doesn’t exist.

I searched ad found that I need to add ~ipad in CFBundleIconFiles but still get the same error!.

Here is the code:

  func changeIcon(to name: String?) {
        //Check if the app supports alternating icons
        guard UIApplication.shared.supportsAlternateIcons else {
            return;
        }

        //Change the icon to a specific image with given name
        UIApplication.shared.setAlternateIconName(name) { (error) in
            //After app icon changed, print our error or success message
            if let error = error {
                print("App icon failed to due to (error.localizedDescription)")
            } else {
                print("App icon changed successfully.")
            }
        }
    }

enter image description here

I just tested on another project and works fine !!! but not on my current project why ?! have you any idea?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.