Support of iOS 5.0 icons with XCode 5

2020-05-23 15:37发布

I'm using the new asset catalog AppIcon to set the right icons for iOS 5 (in theory), 6 and 7. Unfortunately, when installing the application on my iPad 1 (with iOS 5.1.1), the displayed icon is not the right one (it's upscaled from another one, certainly the 57x57 one).

I saw that after creating the asset catalog, 2 empty entries are added in the Info.plist file:

  • Icon files (iOS 5)
  • CFBundleIcons~ipad

I've read a lot of "solutions", but nothing worked for me :(

One of the solution was to add these entries in the plist (and add the corresponding icons in the project):

<key>CFBundleIcons</key>
<dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
        <key>CFBundleIconFiles</key>
        <array>
            <string>Icon.png</string>
            <string>Icon@2x.png</string>
            <string>Icon-72.png</string>
            <string>Icon-72@2x.png</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <true/>
    </dict>
</dict>
<key>CFBundleIcons~ipad</key>
<dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
        <key>CFBundleIconFiles</key>
        <array>
            <string>Icon-Small</string>
            <string>Icon-Small-50</string>
            <string>Icon-72@2x.png</string>
            <string>Icon-72.png</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <true/>
    </dict>
</dict>

But it's not working at all.

I'm using XCode 5.0 (5A1413).

Any help would be really appreciated.

6条回答
Bombasti
2楼-- · 2020-05-23 15:58

I finally found a working solution. I don't use anymore the asset catalog. And I put these lines in my info.plist file:

<key>CFBundleIconFile</key>
<string>Icon-57.png</string>
<key>CFBundleIconFiles</key>
<array>
    <string>Icon-72.png</string>
    <string>Icon-72@2x.png</string>
    <string>Icon-57.png</string>
    <string>Icon-57@2x.png</string>
    <string>Icon-60@2x.png</string>
    <string>Icon-60.png</string>
    <string>Icon-76@2x.png</string>
    <string>Icon-76.png</string>
    <string>Icon-29@2x.png</string>
    <string>Icon-29.png</string>
    <string>Icon-50@2x.png</string>
    <string>Icon-50.png</string>
    <string>Icon-40@2x.png</string>
    <string>Icon-40.png</string>
</array>
<key>CFBundleIcons</key>
<dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
        <key>CFBundleIconFiles</key>
        <array>
            <string>Icon-72@2x.png</string>
            <string>Icon-57.png</string>
            <string>Icon-72.png</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <true/>
    </dict>
</dict>

It's working like a charm now :)

查看更多
【Aperson】
3楼-- · 2020-05-23 16:05

XCode 6.0.1 Update

It appears that XCode 6 Icon Asset catalogs now work properly for iOS5 - iOS8.0.2. I have confirmed this on iPad 1 running iOS 5.1.1. Inspecting the compiled app I have found that XCode properly generated the following Info.plist icon entries and copied the icon files to the app bundle root with the corresponding filenames (This was generated when using a asset catalog named AppIcon - the default):

XCode 6.0.1 Generated Info.plist

This contains icons for all iPad and iPhone devices through iPhone 6+.

查看更多
放我归山
4楼-- · 2020-05-23 16:11

Try this:

Add this to your plist:

<key>CFBundleIcons</key>
    <dict>
        <key>CFBundlePrimaryIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>Icon</string>
                <string>Icon-72</string>
                <string>Icon-Small</string>
                <string>Icon-Small-50</string>
            </array>
        </dict>
    </dict>

And then add the following icon files to the root level of your project (same folder as your xcodeproj file):

Icon-72.png          (72x72)
Icon-72@2x.png       (144x144)
Icon-Small-50.png    (50x50)
Icon-Small-50@2x.png (100x100)
Icon-Small.png       (29x29)
Icon-Small@2x.png    (58x58)

You may or may not need to do all of these steps, but it worked for me. My project uses XCode 5's asset catalogs, but I still had to do this to get a proper icon on iPad1 running iOS 5.1.1 (which is a real shame!)

查看更多
一夜七次
5楼-- · 2020-05-23 16:12

In my case the only solution was to create a new App Icon entry in the assets and make sure the iPad icons are set there.

I was working on an old project in Xcode 5. I let Xcode do some conversions on the old project files which included converting to use assets. The project was iPhone only so the converted App Icon sets in the assets did not contain entries for iPads - not even the slots. When I created a new App Icon, it also included the slots for iPads (the project is still "iPhone only"). Filling all entries resulted in my icon being shown on the iPad 1 (iOS 5.1.1).

Note that I did not have to change the Info.plist. Also I did not have to specify a specific name for the icon files.

查看更多
干净又极端
6楼-- · 2020-05-23 16:18

I've found better solution working on iOS 5 with asset catalog.

Set this in Info.plist (other icons sections like CFBundleIcons are generated and overwritten by Xcode, so leave them empty):

<key>CFBundleIconFiles</key>
<array>
    <string>AppIcon57x57.png</string>
    <string>AppIcon72x72.png</string>
    <string>AppIcon57x57@2x.png</string>
    <string>AppIcon72x72@2x.png</string>
</array>

and add just two more icons in your resources (outside assets):

AppIcon72x72.png
AppIcon72x72@2x.png

This way you will have only two icons duplicated in your bundle.

The source of problem is that asset catalog generates such icons with ~ipad suffixes which iOS 5 doesn't understand, so we have to add these files without ~ipad suffix manually. iOS 6 doesn't have this problem and finds proper icons with and without ~ipad suffix.

Use icon name (AppIcon or Icon or anything else) as you set in your asset catalog.

查看更多
家丑人穷心不美
7楼-- · 2020-05-23 16:21

You can also disable the asset catalog in the interface:

  1. Select your project in the sidebar (the topmost element in the list)
  2. Go to App Icons, click the Source dropdown field and select "Don't use asset catalogs"
  3. Add your images to the project (drop them into the sidebar, you can create a group for them)
  4. Now you can select your images under App Icons, by clicking the little grey folder icons on the right.

My guess is that iOS 5 just doesn't support the asset catalog, so you have to make Xcode 5 use the old way.

查看更多
登录 后发表回答