Icons, Asset Catalog and Info.plist confusion

不羁的心 提交于 2019-12-20 23:09:15

问题


I have an app that started life for iOS 5 and has been updated ever since. For iOS 7 I have switched over to using an Asset Catalog for all the resources, which is nice and appears to work well. However, when I try to submit to Apple I get validation errors:

Invalid Image Path - No image found at the path referenced under key 'CFBundleIconFiles': 'Icon@2x.png'

I get the same error for the other icons, too. These icons do appear in the Asset Catalog and the names -- right down to the case -- match exactly as far as I can tell. The Asset Catalog is in the "Copy Bundle Resources" and all the resources appear in the right place when I run the app on both my iPhone and iPad (in iOS 7) and in the Simulator for iOS 6.

I have updated the app to use the minimum deployment target of iOS 6.

So, how do I successfully submit my update to Apple? Do I need the references in the Info.plist? Are there any other settings that I should check? Is the warning spurious and something that I should ignore (after raising a Radar)?


回答1:


When an asset catalog is compiled for iOS 6 and lower, the images are put in the root of the app bundle, as if you were just copying them the old way. When this happens, Apple names the images according to the asset name, rather than the filename, which means we can still use +[UIImage imageNamed:] to get the assets on iOS 6 and lower.

This is true for the App Icon asset, when we have the following icons set in our asset catalog:

They become compiled like so:

As iOS 6 is still iOS 6, these files must be referenced in the Info.plist, otherwise the existing system wouldn't work. Looking in the compiled Info.plist for this test app, you see that Xcode has added CFBundleIconFiles for us and so we don't need to.

I have uploaded the test project I used to github.com/danielctull-tests/AssetTest.




回答2:


Okay, so here is what I ended up doing. I'm not 100% sure it's correct but I thought that it was worth sharing.

  • I removed CFBundleIconFile, which I don't think is used in iOS 6 and above
  • I used the asset name rather than the icon filename in CFBundleIconFiles

I'm not clear what the proper names are so, for the sake of clarity: by icon filename I mean the name visible in the Attribute Inspector of the Asset Catalog when the icon is selected; and by asset name I mean AppIcon, which refers to seven actual icons in my case.

This both passes Apple's validation step and appears to look okay. I don't currently have an iOS 6 device but it displays correctly in the Simulator.




回答3:


I had also a lot of Problems on this matter - I was constantly getting the error with the missing CFBundleIconName and that my Icons where not found. So here is my story, maybe it will be of help for somebody. By the way, I am using Visual Studio with Xamarin.

  1. Add an Asset Catalogue to your Project with AppIcons (the actual name of the asset is not important but just that it is for the application icons). Add all of the necessary icon sizes. For the 'App Store' icon I have added an icon without a @ in the name as someone in the forums suggested, but I am not sure, if it is 100% necessary. For generating the different icon sizes there are a lot of Websites and tools that can do that for you and you just need to provide the 1024x1024 one. They will generate the rest.

  2. In the Info.plist under 'Visual Assets' and then 'App Icons' set the source to the asset that you have just created.

  3. Now check your Info.plist. Do not open it with an external Editor, because all of your changes will be overwritten once you build your project. Do the following - right mouse click on the Info.plist in the Solution Explorer then select Open With -> Generic PList Editor.

  4. Check that you have the following entries:

    -Property = CFBundleIconName, Type = String. Value = Assets.xcassets/AppIcons.appiconset -Property = XSAppIconAssets, Type = String. Value = Assets.xcassets/AppIcons.appiconset

  5. Note that Visual Studio automatically adds, when it adds something altogether, 'Resources/Assets.xcassets/AppIcons.appiconset' as the Value. But in my case the Asset Catalog was created outside of the Resources folder and therefore, my icons where not found. So, check where your assets folder was created.

  6. CFBundleIconFiles was not needed, because Apple uses the Asset Catalog instead now.

I hope that I was of some help :)



来源:https://stackoverflow.com/questions/19114843/icons-asset-catalog-and-info-plist-confusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!