使用 XCode 5 支持 iOS 5.0 图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19220082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Support of iOS 5.0 icons with XCode 5
提问by Alx
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).
我正在使用新的资产目录 AppIcon 为 iOS 5(理论上)、6 和 7 设置正确的图标。不幸的是,在我的 iPad 1(使用 iOS 5.1.1)上安装应用程序时,显示的图标不是正确的(它是从另一个放大的,当然是 57x57 的)。
I saw that after creating the asset catalog, 2 empty entries are added in the Info.plist
file:
我看到创建资产目录后,Info.plist
文件中添加了2个空条目:
Icon files (iOS 5)
CFBundleIcons~ipad
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):
解决方案之一是在 plist 中添加这些条目(并在项目中添加相应的图标):
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon.png</string>
<string>[email protected]</string>
<string>Icon-72.png</string>
<string>[email protected]</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>[email protected]</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).
我正在使用 XCode 5.0 (5A1413)。
Any help would be really appreciated.
任何帮助将非常感激。
采纳答案by Alx
I finally found a working solution. I don't use anymore the asset catalog. And I put these lines in my info.plist file:
我终于找到了一个可行的解决方案。我不再使用资产目录。我把这些行放在我的 info.plist 文件中:
<key>CFBundleIconFile</key>
<string>Icon-57.png</string>
<key>CFBundleIconFiles</key>
<array>
<string>Icon-72.png</string>
<string>[email protected]</string>
<string>Icon-57.png</string>
<string>[email protected]</string>
<string>[email protected]</string>
<string>Icon-60.png</string>
<string>[email protected]</string>
<string>Icon-76.png</string>
<string>[email protected]</string>
<string>Icon-29.png</string>
<string>[email protected]</string>
<string>Icon-50.png</string>
<string>[email protected]</string>
<string>Icon-40.png</string>
</array>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>[email protected]</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 :)
它现在就像一个魅力:)
回答by thom_ek
I've found better solution working on iOS 5 with asset catalog.
我找到了使用资产目录在 iOS 5 上工作的更好解决方案。
Set this in Info.plist (other icons sections like CFBundleIcons are generated and overwrittenby Xcode, so leave them empty):
在 Info.plist 中设置(其他图标部分如 CFBundleIcons由 Xcode生成并覆盖,因此将它们留空):
<key>CFBundleIconFiles</key>
<array>
<string>AppIcon57x57.png</string>
<string>AppIcon72x72.png</string>
<string>[email protected]</string>
<string>[email protected]</string>
</array>
and add just two more icons in your resources (outside assets):
并在您的资源(外部资产)中再添加两个图标:
AppIcon72x72.png
[email protected]
This way you will have onlytwo 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.
问题的根源在于资产目录生成了iOS 5无法理解的带有~ipad后缀的图标,所以我们必须手动添加这些没有~ipad后缀的文件。iOS 6 没有这个问题,可以找到带有和不带有 ~ipad 后缀的正确图标。
Use icon name (AppIcon or Icon or anything else) as you set in your asset catalog.
使用您在资产目录中设置的图标名称(AppIcon 或 Icon 或任何其他名称)。
回答by Brody Robertson
XCode 6.0.1 Update
XCode 6.0.1 更新
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 图标资产目录现在适用于 iOS5 - iOS8.0.2。我已经在运行 iOS 5.1.1 的 iPad 1 上确认了这一点。检查已编译的应用程序,我发现 XCode 正确生成了以下 Info.plist 图标条目,并将图标文件复制到具有相应文件名的应用程序包根目录(这是在使用名为 AppIcon 的资产目录时生成的 - 默认值):
This contains icons for all iPad and iPhone devices through iPhone 6+.
这包含所有 iPad 和 iPhone 设备到 iPhone 6+ 的图标。
回答by Quentin
Try this:
尝试这个:
Add this to your plist:
将此添加到您的 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):
然后将以下图标文件添加到项目的根级别(与 xcodeproj 文件相同的文件夹):
Icon-72.png (72x72)
[email protected] (144x144)
Icon-Small-50.png (50x50)
[email protected] (100x100)
Icon-Small.png (29x29)
[email protected] (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!)
您可能需要也可能不需要执行所有这些步骤,但它对我有用。我的项目使用 XCode 5 的资产目录,但我仍然必须这样做才能在运行 iOS 5.1.1 的 iPad1 上获得正确的图标(这真是太可惜了!)
回答by Alex Wally
You can also disable the asset catalog in the interface:
您还可以在界面中禁用资产目录:
- Select your project in the sidebar (the topmost element in the list)
- Go to App Icons, click the Source dropdown field and select "Don't use asset catalogs"
- Add your images to the project (drop them into the sidebar, you can create a group for them)
- 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.
我的猜测是 iOS 5 只是不支持资产目录,所以你必须让 Xcode 5 使用旧的方式。
回答by Rainer Schwarze
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.
就我而言,唯一的解决方案是在资产中创建一个新的应用程序图标条目,并确保在那里设置 iPad 图标。
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).
我正在 Xcode 5 中处理一个旧项目。我让 Xcode 对旧项目文件进行一些转换,其中包括转换为使用资产。该项目仅适用于 iPhone,因此资产中转换后的应用程序图标集不包含 iPad 的条目——甚至不包含插槽。当我创建一个新的应用程序图标时,它还包括 iPad 的插槽(该项目仍然是“仅限 iPhone”)。填写所有条目导致我的图标显示在 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.
请注意,我不必更改 Info.plist。此外,我不必为图标文件指定特定名称。