I try to set alternative icons for my application in iOS 10.3
, but every time I call the Xcode method, it returns:
Domain Error = NSCocoaErrorDomain Code = 3072 "Operation was canceled."
I use @KlimczakM's answer from this to set the icon ( specifyIcon
method below), but I use my own method to load the preferred icon from the settings:
let iconSetting = userDefaults.string(forKey: "appIconSetting") print("The icon setting is: \(iconSetting ?? "error getting appIconSetting.")") switch iconSetting! { case "white": specifyIcon(nil) case "dark": specifyIcon("dark") case "text": specifyIcon("text") case "textdark": specifyIcon("textdark") case "rainbow": specifyIcon("rainbow") default: specifyIcon(nil) print("ERROR setting icon.") } func specifyIcon(_ icon: String?) {
In my Info.plist
I have five icons; white
, dark
, rainbow
, text
and textdark
:
<key>CFBundleIcons</key> <dict> <key>CFBundleAlternateIcons</key> <dict> <key>white</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_white</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>dark</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_dark</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>rainbow</key> <dict> <key>CFBundleIconFiles</key> <array> <string>rainbow</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>text</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_text</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> <key>textdark</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_textdark</string> </array> <key>UIPrerenderedIcon</key> <false/> </dict> </dict> <key>CFBundlePrimaryIcon</key> <dict> <key>CFBundleIconFiles</key> <array> <string>ic_white</string> </array> </dict> </dict>
All these icons are contained as PNG files in the "resources" folder inside my application package.
How can I fix this problem?
source share