admaDIC App Development & IT Solutions

Alternate App Icons

by Annett Schwarze | 2025-12-12

An amazing addition to an app are color themes. Setting alternate App Icons is an excellent addition to that.

Apple provides the function `setAlternateIconName` to do that. There are some limitations, so one cannot update the icon too frequently.

For the example two icons were created with Icon Composer. One is set as the standard app icon and the other is added to the build setting `ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES` ("Alternate App Icon Sets").

        
class ThemeManager: ObservableObject {
    @Published var currentTheme: AppTheme = .standard
    private var timerCancellable: AnyCancellable?

    init() {
        let themeName = UserDefaults.standard.object(forKey: "currentTheme") as? String ?? "standard"
        let theme = AppTheme(rawValue: themeName) ?? .standard
        currentTheme = theme
    }

    func updateTheme(_ theme: AppTheme) {
        currentTheme = theme
        UserDefaults.standard.set(currentTheme.rawValue, forKey: "currentTheme")
        updateAppIcon()
    }

    func updateAppIcon() {
        switch currentTheme {
        case .standard:
            UIApplication.shared.setAlternateIconName(nil, completionHandler: { error in
                if let error {
                    print("error: \(String(describing: error))")
                }
            })
        case .christmas:
            UIApplication.shared.setAlternateIconName("AppIcon-Christmas", completionHandler: { error in
                if let error {
                    print("error: \(String(describing: error))")
                }
            })
        }
    }
}
    
SwiftUI Color Themes

 

www.admadic.de | webmaster@admadic.de | Legal Notice and Trademarks | Privacy
© 2005-2007 - admaDIC | All Rights Reserved
All other trademarks and/or registered trademarks are the property of their respective owners
Last Change: Fri Dec 12 09:40:09 2025 GMT