Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize app icon as build phase in Xcode 9/iOS 11

My app is setup to add a banner to the app icon based on the configuration being build. It was done following these steps.

https://www.raywenderlich.com/105641/change-app-icon-build-time

As of Xcode 9/iOS 11, this doesn't seem to work anymore. The images are still correctly being modified and they exist in the app bundle, but they are not being used as the app icon on the device.

Is there any way to do this again?

like image 509
Craig Siemens Avatar asked Sep 13 '17 18:09

Craig Siemens


People also ask

How do I change my app Store icon in Xcode?

In the Project navigator, select an asset catalog. Click the Add button (+) at the bottom of the outline view. In the pop-up menu, choose a platform, and select [OS] App Icon. Xcode creates a new app icon set with the name AppIcon .

How do I change my app icons on Apple?

Tap on the icon under Home Screen Name and Icon. You'll have the choice of either taking a photo, choosing a photo, or choosing a file. Assuming you've already saved an image in Photo, tap on Choose Photo and select the photo you want to use.


1 Answers

Here's the solution I ended up going with.

  1. Remove the app icons from Assets.xcassets
  2. Create new xcassets for each configuration that needs a custom icon. I named them AppIcon-{CONFIGUATION}.xcassets
  3. Create a default AppIcon.xcassets file for release builds.
  4. In the targets build settings, add the following to Excluded Source File Names
$(SRCROOT)/$(PRODUCT_NAME)/AppIcon*.xcassets
  1. Also in the targets build settings, add the following to Included Source File Names, customizing for each configuration as needed.
$(SRCROOT)/$(PRODUCT_NAME)/AppIcon-Debug.xcassets

This will cause the built application to only include the app icon assets for configuration being built. This can also be extended to other assets.

like image 179
Craig Siemens Avatar answered Sep 21 '22 02:09

Craig Siemens