使用XCode 5支持iOS 5.0图标

我正在使用新的资产目录AppIcon为iOS 5(理论上),6和7设置正确的图标。不幸的是,在我的iPad 1(iOS 5.1.1)上安装应用程序时,显示的图标不是正确的一个(从另一个上升,当然是57×57)。

我看到在创build资产目录之后, Info.plist文件中添加了两个空条目:

  • Icon files (iOS 5)
  • CFBundleIcons~ipad

我读过很多“解决scheme”,但没有为我工作:(

其中一个解决scheme是将这些条目添加到plist中(并在项目中添加相应的图标):

 <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> 

但它根本不工作。

我正在使用XCode 5.0(5A1413)。

任何帮助将非常感激。

我终于find一个工作解决scheme。 我不再使用资产目录。 我把这些行放在我的info.plist文件中:

 <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> 

它现在像一个魅力工作:)

我已经find了更好的解决scheme,在iOS 5上使用资产目录。

在Info.plist中设置(像CFBundleIcons这样的其他图标部分是由Xcode生成和覆盖的,所以将它们留空):

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

并在您的资源(外部资产)中仅添加两个图标:

 AppIcon72x72.png AppIcon72x72@2x.png 

这样你的捆绑只有两个图标被复制。

问题的根源在于,资产目录会生成带有iOS 5不能理解的〜ipad后缀的图标,所以我们必须手动添加这些没有〜ipad后缀的文件。 iOS 6没有这个问题,并find适当的图标有和没有〜ipad后缀。

使用您在资产目录中设置的图标名称(AppIcon或Icon或其他)。

XCode 6.0.1更新

看来XCode 6 Icon Asset目录现在可以在iOS5 – iOS8.0.2上正常使用。 我已经在运行iOS 5.1.1的iPad 1上确认了这一点。 检查已编译的应用程序,我发现XCode正确地生成了以下Info.plist图标条目,并将图标文件复制到应用程序包根目录(使用名为AppIcon的资产目录 – 默认值时生成):

XCode 6.0.1生成Info.plist

这包含通过iPhone 6+的所有iPad和iPhone设备的图标。

尝试这个:

添加到您的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> 

然后将以下图标文件添加到项目的根级别(与xcodeproj文件相同的文件夹):

 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) 

您可能需要也可能不需要完成所有这些步骤,但它对我有用。 我的项目使用XCode 5的资产目录,但我仍然必须这样做才能在运行iOS 5.1.1的iPad1上获得正确的图标(这真是太遗憾了!)

您也可以在界面中禁用资产目录:

  1. 在侧边栏中select您的项目(列表中最顶端的元素)
  2. 转到应用程序图标,单击来源下拉字段,然后select“不要使用资产目录”
  3. 将你的图片添加到项目中(把它们放到边栏中,你可以为它们创build一个组)
  4. 现在,您可以通过点击右侧的小灰色文件夹图标来select应用程序图标下的图像。

我的猜测是,iOS 5只是不支持资产目录,所以你必须使Xcode 5使用旧的方式。

在我的情况下,唯一的解决scheme是在资产中创build一个新的应用程序图标条目,并确保iPad图标设置在那里。

我正在使用Xcode 5中的旧项目。我让Xcode对旧项目文件进行了一些转换,包括转换为使用资产。 该项目只有iPhone,因此资产中已转换的应用程序图标集不包含iPad的条目 – 甚至没有插槽。 当我创build一个新的应用程序图标,它还包括iPad的插槽(该项目仍然是“仅iPhone”)。 填写所有条目导致我的图标显示在iPad 1(iOS 5.1.1)上。

请注意,我不必更改Info.plist。 此外,我不必为图标文件指定一个特定的名称。