iosxcodeinfo.plistcfbundleicons

Xcode/iOS - CFBundleAlternateIcons not changing


I've been trying to change my app icon using CFBundleAlternateIcons, but nothing happens. I'm actually using a plugin for the Flutter SDK - flutter_dynamic_icon, when I change the icon using the plugin, it says 'App icon change successful' as if nothing's wrong.

After doing some troubleshooting, I've also tried resaving the icons in Preview to ensure they're PNG files, and removing their alpha channels, with no change in results.

What am I doing wrong? Is it an Info.plist issue? Are my icons saved incorrectly? Am I calling for the icon change incorrectly?

This is how I try to change the icon in dart lang:

try {
  if (await FlutterDynamicIcon.supportsAlternateIcons) {
    await FlutterDynamicIcon.setAlternateIconName("dark");
    print("App icon change successful");
    return;
  }
} on PlatformException {} catch (e) {
  print("icon couldn't be changed");
}

This is what I see, never mind if I click to change to dark icon or light icon.

false positive

Here's my Info.plist / file structure:

<key>CFBundleIcons</key>
<dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
        <key>light</key>
        <dict>
            <key>UIPrerenderedIcon</key>
            <string>NO</string>
            <key>CFBundleIconFiles</key>
            <array>
                <string>light</string>
            </array>
        </dict>
        <key>dark</key>
        <dict>
            <key>UIPrerenderedIcon</key>
            <string>NO</string>
            <key>CFBundleIconFiles</key>
            <array>
                <string>dark</string>
            </array>
        </dict>
    </dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
        <key>CFBundleIconFiles</key>
        <array>
            <string>dark</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <false/>
    </dict>
</dict>

info.plist - property list

file structure


Solution

  • EDIT: I've now figured out my issue, despite online guides advising you to place the alternate icons in a separate folder, my case only works if I place said icons directly inside the Runner directory.


    I fixed this by defining the CFBundleIconFiles in Info.plist as follows. It's a subtle change, but can make or break the process.

    Before:

    <key>CFBundleIcons</key>
    <dict>
        <key>CFBundleAlternateIcons</key>
        <dict>
            <key>light</key>
            <dict>
                <key>UIPrerenderedIcon</key>
                <string>NO</string>
                <key>CFBundleIconFiles</key>
                <array>
                    <string>light</string>
                </array>
            </dict>
            <key>dark</key>
            <dict>
                <key>UIPrerenderedIcon</key>
                <string>NO</string>
                <key>CFBundleIconFiles</key>
                <array>
                    <string>dark</string>
                </array>
            </dict>
        </dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>dark</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
    </dict>
    

    After:

    <key>CFBundleIcons</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>light</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
        <key>CFBundleAlternateIcons</key>
        <dict>
            <key>light</key>
            <dict>
                <key>CFBundleIconFiles</key>
                <array>
                    <string>light</string>
                </array>
                <key>UIPrerenderedIcon</key>
                <false/>
            </dict>
            <key>dark</key>
            <dict>
                <key>CFBundleIconFiles</key>
                <array>
                    <string>dark</string>
                </array>
                <key>UIPrerenderedIcon</key>
                <false/>
            </dict>
        </dict>
    </dict>
    

    Property list:

    property list, shows 'CFBundleAlternateIcons', with children 'dark' and 'light' for each alt icon type.

    Xcode project directory:

    enter image description here