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 preferred
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/iPad-app@2x.png
pixelWidth: 152
.../AppIcon-Dark/iPad-pro@2x.png
pixelWidth: 167
.../AppIcon-Dark/iPhone-app@2x.png
pixelWidth: 120
.../AppIcon-Dark/iPhone-app@3x.png
pixelWidth: 180
you can then add/insert the following in your info.plist
CFBundleIcons
CFBundleAlternateIcons
AppIcon-Dark
CFBundleIconFiles
iPhone-app
CFBundlePrimaryIcon
CFBundleIconFiles
AppIcon
CFBundleIcons~ipad
CFBundleAlternateIcons
AppIcon-Dark
CFBundleIconFiles
iPad-app
iPad-pro
CFBundlePrimaryIcon
CFBundleIconFiles
AppIcon
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))")
}
}
}
}