Changing alternate icon for iPad
Attempting to give a more re-useable (easy to copy/paste) version of this answer.
1) You need images of the following names and sizes added as regular .png files (no asset catalogues)
.../AppIcon-Dark/iPad-app.png
pixelWidth: 76
.../AppIcon-Dark/[email protected]
pixelWidth: 152
.../AppIcon-Dark/[email protected]
pixelWidth: 167
.../AppIcon-Dark/[email protected]
pixelWidth: 120
.../AppIcon-Dark/[email protected]
pixelWidth: 180
you can then add/insert the following in your info.plist
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>AppIcon-Dark</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>iPhone-app</string>
</array>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon</string>
</array>
</dict>
</dict>
<key>CFBundleIcons~ipad</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>AppIcon-Dark</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>iPad-app</string>
<string>iPad-pro</string>
</array>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon</string>
</array>
</dict>
</dict>
I then set my icon with the following
func updateIcon() {
if #available(iOS 13.0, *) {
let dark = window?.traitCollection.userInterfaceStyle == .dark
let currentIconName = UIApplication.shared.alternateIconName
let desiredIconName:String? = dark ? "AppIcon-Dark" : nil
if currentIconName != desiredIconName {
UIApplication.shared.setAlternateIconName(desiredIconName) {
(error) in
print("failed: \(String(describing: error))")
}
}
}
}
Your info.plist is structured incorrectly.
You have:
- CFBundleIcons
- CFBundleAlternateIcons
- Icon Name
- CFBundleIconFiles
- CFBundleIconFiles~ipad
But it should be:
- CFBundleIcons
- CFBundleAlternateIcons
- Icon Name
- CFBundleIconFiles
- CFBundleIcons~ipad
- CFBundleAlternateIcons
- Icon Name
- CFBundleIconFiles
Basically, once you have it working with iPhone icons, CFBundleIcons
, duplicate the entire tree as CFBundleIcons~ipad
. The iPad files shouldn't be nested under CFBundleIcons
at all.
You're mixing up CFBundleIcons~ipad
and CFBundleIconFiles~ipad
(which isn't a valid key).