Xamarin iOS发布报错:Info.plist缺少CFBundleIconName值求解决
Hey there, I’ve run into this exact CFBundleIconName error a few times when working with Xamarin iOS apps, so let’s walk through some practical fixes to get you past this:
1. Manually Add CFBundleIconName to Info.plist
Sometimes the visual editor in Visual Studio fails to auto-populate this key, even when you set up the icon set. Here’s how to fix it:
- Right-click your
Info.plistfile and select Open With > XML (Text) Editor - Inside the
<dict>section, add these lines (replaceAppIconwith your actual icon set name if it’s different):<key>CFBundleIconName</key> <string>AppIcon</string> - Save the file and close the text editor.
2. Verify Your Asset Catalog Icon Set Configuration
Double-check that your icon set is properly set up in the Asset Catalog:
- Open your
Assets.xcassetsfile (or the catalog you created) - Select your icon set (e.g., AppIcon) and confirm all required icon sizes have been imported correctly (no missing placeholders)
- Right-click the icon set and choose Show in Finder, then open the
Contents.jsonfile. Make sure each entry has a validfilenameand matches the size requirements for iOS. If the App Icon Set Creator generated a wonky JSON, you might need to regenerate the icon set or tweak the file manually.
3. Clean, Clear Caches, and Rebuild
Cached build files often cause weird issues like this. Let’s do a full reset:
- In Visual Studio, go to Build > Clean Solution
- Navigate to your project’s root folder and delete the
binandobjfolders (these hold cached build artifacts) - Go back to Visual Studio and select Build > Rebuild Solution
4. Double-Check Info.plist’s Visual Resource Settings
Make sure the visual editor is actually linking to your correct icon set:
- Open
Info.plistin the visual editor and go to the Visual Resources tab - Under App Icons, check that the Source dropdown is set to your icon set (not empty or pointing to a deleted folder)
- If it’s not selected, choose your icon set from the dropdown and save the changes.
5. Validate the Final Bundle
After rebuilding, let’s confirm everything is in place:
- Find your generated
.appbundle (usually inbin/iPhone/DebugorReleasefolder) - Right-click it and select Show Package Contents
- Check that
Assets.carexists (this is the compiled Asset Catalog) - Open the bundled
Info.plistand verify theCFBundleIconNamekey is present and has the correct value.
If none of these steps work, try creating a brand new Asset Catalog from scratch, reimporting your icons, and re-linking it to Info.plist. Updating Xamarin and Visual Studio to the latest stable version can also help, as older versions sometimes have bugs with Asset Catalog handling.
内容的提问来源于stack exchange,提问作者solarissf

