Use image file from "Assets.xcassets" for changing iOS app icon programmatically

1.3k Views Asked by At

I'm trying to develop Icon Changing feature and I was going to use images from Assets.xcassets as app icon image.

I tried changing app icon using setAlternateIconName(_:completionHandler:) after adding CFBundleAlternateIcons data to info.plist But Xcode and iOS System cannot detect image file from Assets.xcassets. I want to use image from Assets.xcassets as App icon. Is there any way?

Thanks in advance

2

There are 2 best solutions below

0
Farrukh Makhmudov On BEST ANSWER

No, you cannot use assets for that. But if your purpose is to adapt images for devices. Just add a suffix ( for example [email protected] , [email protected], [email protected])

Check this link for details

0
Victor Bogdan On

If you want to use the AppIcon image (in your "main" .xcassets bundle) with setAlternateIconName(_:completionHandler:), you should:

Specify nil if you want to display the app’s primary icon

The alternate icons should live outside of any .xcassets bundle. As you mentioned, it seems those aren't supported for setting alternate icons.

Source: https://developer.apple.com/documentation/uikit/uiapplication/2806818-setalternateiconname