15

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?

austintt
  • 485
  • 1
  • 4
  • 13
  • Does this answer your question? [Changing alternate icon for iPad](https://stackoverflow.com/questions/51949430/changing-alternate-icon-for-ipad) – HangarRash Mar 04 '23 at 20:35

4 Answers4

14

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.

austintt
  • 485
  • 1
  • 4
  • 13
11

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)
Gonzo
  • 1,533
  • 16
  • 28
  • 3
    Almost there, you got me on the right path though. I needed a second copy of the CFBundleIcons, with the ~ipad suffix. Thank you! Sorry I accidentally deleted your comment earlier. The buttons were so small and I was a bit too fidgety. – austintt Mar 26 '18 at 23:17
  • Yeah, that's write. I forgot it. That necessary setup is a little bit confusing and I never used this feature myself. No problems with the deleted comment – Gonzo Mar 26 '18 at 23:22
  • @austintt would you check this Q ? https://stackoverflow.com/questions/51949430/changing-alternate-icon-for-ipad/52015354#52015354 – iOS.Lover Aug 25 '18 at 08:32
  • What naming for supporting all iPads? –  May 28 '19 at 02:38
  • 5
    If @2x are required for iPad (152px) and iPad Pro (167px), then what's the correct naming convention? For example, I have 'blueAppIcon@2x~ipad.png' as a loose file in my project (that is 152px), but if I want to add another file for iPad Pro, what should it be called? – David Steppenbeck Sep 12 '19 at 20:27
  • 1
    Ok, naming is same as iPhone. Just dupe the CFBundleIcons (and name the dupe `CFBundleIcons~ipad`) tree. Of course, if you actually want different qualities for different screen sizes, you can name the different sizes differently and edit the dupe tree. –  Nov 04 '19 at 06:43
  • It isn't clear what the exact names and sizes should be in order to support all devices. – twodayslate Sep 25 '20 at 20:07
  • For iPad pro use: AppIcon-Pink-83.5@2x. More info here https://stackoverflow.com/questions/48341607/what-is-the-correct-app-icon-appicon-naming-convention-for-xcode-9-2 – arcangel06 Oct 21 '20 at 06:39
4

enter image description herePlease do following setting to plist for setting alternate icon for ihone andiPad

Rizwan Shaikh
  • 273
  • 3
  • 8
1

With Xcode 13+ no need to work with files/plist manually anymore. You just need to set to YES the “Include All App Icon Assets” setting under build settings. Or click on "Your Target" - General - App Icons and Launch Screen - Include All App Icon Assets.

Include app icon assets

After that just add icons to xcassets catalog. (For some reason it doesn't always work on iPad with a Single Size icons, so you should better use Icon Set with all icon sizes).

Better avoid using symbols in the name of icons. It didn't work for me on iPad with icon name "Icon-Red", but it worked fine with "IconRed"

Swift sample

UIApplication.shared.setAlternateIconName("IconRed", completionHandler: nil)

Obj-C sample

[[UIApplication sharedApplication] setAlternateIconName:@"IconRed" completionHandler:nil];
D1mers0n
  • 460
  • 6
  • 9