Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do my alternate icons work on iPhone but not on iPad?

Tags:

xcode

ios

swift

When I build and deploy to an iPhone, I can call UIApplication.shared.setAlternateIconName just fine. When I run on an iPad Pro, I get the following error:

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

Using the following code:

UIApplication.shared.setAlternateIconName(icons[indexPath.row].name) { err in
            if let err = err {
                print("Woops ! \(String(describing: err))")
            }
        }

I have standard, 2x, and 3x versions of each icon ranging from 60x60, 120x120, and 180x180. These images are placed loosely in the project, not in an assets bundle.They are referenced in my Info.plist.

What is going on? Why is there a difference between iPhone and iPad?

like image 756
austintt Avatar asked Mar 26 '18 22:03

austintt


2 Answers

A separate CFBundleIcons entry in Info.plist is needed specifically for the iPad. It must be named CFBundleIcons~ipad. Just copy your current CFBundleIcons entry and rename it.

like image 131
austintt Avatar answered Sep 20 '22 05:09

austintt


You have to add images for the ipad resolutions too. And they're name must be something like icon@2x~ipad.png. That ~ipad is the difference

The sizes for ipad are

iPad Pro        167px × 167px (83.5pt × 83.5pt @2x)
iPad, iPad mini 152px × 152px (76pt × 76pt @2x)
like image 24
Gonzo Avatar answered Sep 23 '22 05:09

Gonzo