7

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?

Craig Siemens
  • 12,942
  • 1
  • 34
  • 51

2 Answers2

3

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.

Craig Siemens
  • 12,942
  • 1
  • 34
  • 51
0

I dug around in this. The problem is that icons (along with everything else in the asset catalog) get's packaged into a .car file, and then that is used instead of individual files. I've got no idea why the actual icon files are still being copied into the build folder (perhaps they're used for representation obscure place like the builds list in xcode or something like that). If you want to change the icons in a build script, than you could repack the .car file using actool. Or you would need to alter the images pre compile. Or you could potentially take apart the compilation script in xcode and find the place where it packages the .car file and then change do some pre-trickery there. Regardless, it's going to be quite hard to change the icons in the intermediary build folder.

Theis Egeberg
  • 2,556
  • 21
  • 30