Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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.
Here's my Info.plist / file structure:
<key>CFBundleIcons</key>
<key>CFBundleAlternateIcons</key>
<key>light</key>
<key>UIPrerenderedIcon</key>
<string>NO</string>
<key>CFBundleIconFiles</key>
<array>
<string>light</string>
</array>
</dict>
<key>dark</key>
<key>UIPrerenderedIcon</key>
<string>NO</string>
<key>CFBundleIconFiles</key>
<array>
<string>dark</string>
</array>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<key>CFBundleIconFiles</key>
<array>
<string>dark</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
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>
<key>CFBundleAlternateIcons</key>
<key>light</key>
<key>UIPrerenderedIcon</key>
<string>NO</string>
<key>CFBundleIconFiles</key>
<array>
<string>light</string>
</array>
</dict>
<key>dark</key>
<key>UIPrerenderedIcon</key>
<string>NO</string>
<key>CFBundleIconFiles</key>
<array>
<string>dark</string>
</array>
</dict>
</dict>
<key>CFBundlePrimaryIcon</key>
<key>CFBundleIconFiles</key>
<array>
<string>dark</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
After:
<key>CFBundleIcons</key>
<key>CFBundlePrimaryIcon</key>
<key>CFBundleIconFiles</key>
<array>
<string>light</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>CFBundleAlternateIcons</key>
<key>light</key>
<key>CFBundleIconFiles</key>
<array>
<string>light</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
<key>dark</key>
<key>CFBundleIconFiles</key>
<array>
<string>dark</string>
</array>
<key>UIPrerenderedIcon</key>
<false/>
</dict>
</dict>
</dict>
Property list:
Xcode project directory:
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.