If you had ever tried to add Alternate App Icons prior to WWDC 2021, you would have likely been frustrated after finding out alternate app icons must be added to the target file by file, without any easy way to see if you covered all the different sizes, and you had to manually define the structure for each icon in the
Well, no more! As of Xcode 13, Asset Catalogs now support Alternate App Icons and there’s a corresponding build setting to enable the feature:
At runtime, your app can now use iOS app icon assets from its asset catalog as alternate app icons. A new build setting, “Include all app icon assets,” controls whether Xcode includes all app icon sets in the built product. When the setting is disabled [sic], Xcode includes the primary app icon, along with the icons specified in the new setting, “Alternate app icon sets.” The asset catalog compiler inserts the appropriate content into the Info.plist of the built product. (33600923)
To show you exactly how this works, here’s a sample app made with SwiftUI:
The code for this app is the same as it would have been with versions prior to Xcode 13, except
RelationshipIcon now refers to a new App Icon I’ve added to my default Asset Catalog:
And finally, to put it all together, we need to change two settings in the target’s Build Settings.
- In your project’s xcodeproj configuration, select the Build Settings tab.
- Under the Asset Catalog Compiler — Options group, change “Include All App Icon Assets” to Yes.
- Under the same group, add the names of your assets (the ones you used in the Asset Catalog) to “Alternate App Icon Sets”. Here I’ve only added
RelationshipIconbut the option supports adding multiple icons.
The best part is that the new feature is in the build process itself, so you can start using this now with any apps targeting iOS 10.3 or later. As soon as Apple starts accepting apps built with Xcode 13, that is.