Xcode 目标图标未显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18982899/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:54:09  来源:igfitidea点击:

Xcode target icon not displayed

iosxcode

提问by Andy Bowskill

Whilst trying the AFNetworking iOS example project I noticed that Xcode was displaying the target icon. Xcode does not do the same for my own projects/targets however.

在尝试 AFNetworking iOS 示例项目时,我注意到 Xcode 正在显示目标图标。然而,Xcode 不会为我自己的项目/目标做同样的事情。

AFNetworking iOS example project that shows the target icon:

显示目标图标的 AFNetworking iOS 示例项目:

AFNetworking iOS example project

AFNetworking iOS 示例项目

A project that does not show the target icon:

一个不显示目标图标的项目:

A project that does not show the target icon

不显示目标图标的项目

The only difference I can see between both projects is that the AFNetworking iOS example target has an 'Icon files (iOS 5)' ('CFBundleIcons' raw key) dictionary within *-Info.plist. Surely this cant be the source of the problem though given that my example project is targeting iOS 7? Both targets do have an 'Icon files' ('CFBundleIconFiles' raw key) array within *-Info.plist.

我在两个项目之间看到的唯一区别是 AFNetworking iOS 示例目标在 *-Info.plist 中有一个“图标文件(iOS 5)”(“CFBundleIcons”原始键)字典。考虑到我的示例项目是针对 iOS 7 的,这肯定不是问题的根源吗?两个目标在 *-Info.plist 中都有一个“图标文件”(“CFBundleIconFiles”原始键)数组。

Please could someone help to shed light on where Xcode is looking for the target icon?

请有人帮助阐明Xcode在哪里寻找目标图标?

采纳答案by Matt W.

To get the icon to appear you have to have the App Icon (Icon-72.png) in the root directory of your project.

要使图标出现,您必须在项目的根目录中有应用程序图标 (Icon-72.png)。

If you've changed the App Icon name, you must change the correct properties (CFBundleIconFile, CFBundleIconFiles, and CFBundleIcons) in the Info.plist to the changed App Icon file name.

如果您更改了应用程序图标名称,则必须将 Info.plist 中的正确属性(CFBundleIconFile、CFBundleIconFiles 和 CFBundleIcons)更改为更改后的应用程序图标文件名。

(This part doesn't matter, but I've found it works much better if you do.) Fully qualify your info plist file in your target build settings with the following variable name: $(SRCROOT)/your_plist_file_name.plist (of course changing "your_plist_file_name" to the correct name)

(这部分无关紧要,但我发现如果您这样做的话效果会更好。)使用以下变量名称在目标构建设置中完全限定您的信息 plist 文件:$(SRCROOT)/your_plist_file_name.plist(当然将“your_plist_file_name”更改为正确的名称)

I've also found you have to change your target's info plist to a different plist, then back to the correct plist file in order for the icon to show in the build settings. You'll also have to click away from the project file and then back in order for it to show in the list of targets.

我还发现您必须将目标的信息 plist 更改为不同的 plist,然后返回到正确的 plist 文件,以便图标显示在构建设置中。您还必须单击远离项目文件,然后返回以使其显示在目标列表中。

I'm using Xcode 5, but this should work on Xcode 4 and above.

我使用的是 Xcode 5,但这应该适用于 Xcode 4 及更高版本。

Good Luck.

祝你好运。

回答by chamalabey

I tried all the above and did not fixed the icon issue. I was using assets catalog for the project and X-Code version was 5.0.2.

我尝试了以上所有方法,但没有解决图标问题。我正在为项目使用资产目录,X-Code 版本是 5.0.2。

Following steps fixed my issue:

以下步骤解决了我的问题:

  1. Select the Project file from the navigator and select the target which you do not have the icons
  2. Then select Build Phases and expand and Copy Bundle Resources
  3. Add the *.xcassets file to the bundle resources (In my project the file name was Images.xcassets)
  4. Clean and build the target.
  1. 从导航器中选择项目文件并选择您没有图标的目标
  2. 然后选择构建阶段并展开和复制捆绑资源
  3. 将 *.xcassets 文件添加到捆绑资源中(在我的项目中,文件名为 Images.xcassets)
  4. 清理并构建目标。

回答by Deepesh

Please flow the step

请流动步骤

1)Click on the app icon arrow

1)点击应用图标箭头

enter image description here

在此处输入图片说明

2) drag the app icon 120*120 px

2) 拖动应用图标 120*120 px

enter image description here

在此处输入图片说明

3) fisrt time click on the scheme then show the app icon or rest the simulator and again run

3)第一次点击方案然后显示应用程序图标或休息模拟器并再次运行

enter image description here

在此处输入图片说明

回答by Maria

If using the Asset Catalog, select Images.xcassets and look in File Inspector. Check the target membership and make sure your target is selected.

如果使用资产目录,请选择 Images.xcassets 并查看文件检查器。检查目标成员资格并确保选择了您的目标。

回答by Vaibhav Saran

See this screenshot:

看这个截图:

Here Blue are dimensions and red are icon names. Like 57-57is actually 57-57.png. Put all these icons in the root of the project with .xcodeprojfile. Add them into the project. Then set them all accordingly in Target > Project Name > General

这里蓝色是尺寸,红色是图标名称。喜欢57-57实际上是57-57.png。将所有这些图标与.xcodeproj文件一起放在项目的根目录中。将它们添加到项目中。然后相应地将它们全部设置在Target > Project Name > General

Doing this will start showing every icon at its place in XCodeautomatically. enter image description here

这样做将开始XCode自动在其位置显示每个图标。 在此处输入图片说明