Search code examples
iosxcodeios11xcode9

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?


Solution

  • 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.