ios 应用程序图标没有出现,虽然我已经在 Xcode 5 中添加了

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

App Icon not showing up, although I have added in Xcode 5

iosxcodeicons

提问by ivesingh

I have added the icon as shown in the pic below but I am still not seeing the icon in my device or simulator.

我已经添加了如下图所示的图标,但我仍然没有在我的设备或模拟器中看到该图标。

enter image description here

在此处输入图片说明

回答by CodeBrew

This might be an XCode 5 bug that the added icons are not actually included in the app bundle, but you can work around it by going to Build Phases, expand Copy Bundle Resources, then press the "+" sign in the bottom to manually add the icon files to this category.

这可能是一个 XCode 5 错误,即添加的图标实际上并未包含在应用程序包中,但您可以通过转到构建阶段,展开复制包资源,然后按底部的“+”号手动添加来解决它图标文件到这个类别。

In addition iOS 5/6 seems to have a bug that the screen doesn't update the app icon even if the icon files are included in the bundle. To work around it (as suggested by josema.vitaminew at App Icon not changing when app version is updated in iOS 5 simulator) you can drag the app icon into a folder, then iOS will update the appearance of it.

此外,iOS 5/6 似乎有一个错误,即使图标文件包含在捆绑包中,屏幕也不会更新应用程序图标。要解决它(如 josema.vitaminew 在App Icon 的建议,当应用程序版本在 iOS 5 模拟器中更新时不会改变),您可以将应用程序图标拖到一个文件夹中,然后 iOS 将更新它的外观。

回答by Adriano Lucas

If using the Asset Catalog, it might be worth also checking whether Images.xcassetsholds all your targets as shown in the below image.

如果使用资产目录,可能还需要检查是否Images.xcassets包含所有目标,如下图所示。

enter image description here

在此处输入图片说明

回答by Zack Morris

Expanding on adp's answer, if anyone has switched to asset catalogs but they stopped working, and still can't find a solution for Asset Catalog, Images.xcassets, AppIcon or LaunchImage not working, here is a reproduction of the same problem I encountered, and the solution:

扩展 adp 的答案,如果有人切换到资产目录但他们停止工作,并且仍然找不到资产目录、Images.xcassets、AppIcon 或 LaunchImage 不工作的解决方案,这里是我遇到的相同问题的再现,和解决方案:

I had upgraded to Xcode 6 and opened a project created by an earlier version (4 or 5, not sure) and no matter what I did, AppIcons and LaunchImages absolutely would show up when I ran the app in either iOS Simulator or the device.

我已经升级到 Xcode 6 并打开了一个由早期版本(4 或 5,不确定)创建的项目,无论我做什么,当我在 iOS 模拟器或设备中运行应用程序时,AppIcons 和 LaunchImages 绝对会出现。

  • I tried Xcode->Product->Clean, Xcode->Window->Organizer->Projects->Derived Data->Delete..., relaunching Xcode and the iOS Simulator, then rebuilding and relaunching the app (failed).

  • I tried "Reset Contents and Settings..." in iOS Simulator and even deleting ~/Library/Developer/Xcode/DerivedData//Build/Products/Debug-iphoneos and relaunching the app (failed).

  • I tried archiving the project, hoping that it was just an issue with the iOS Simulator, but the icon in the Organizer-Archives window was still shown as the default white square with lines, confirming that the icon would also not show on a device (a helpful trick to have when no device is handy). (failed).

  • I tried choosing "Don't use asset catalogs" in Target Settings and creating a new AppIcon-2 and LaunchImage-2 (failed). -this is what cost me at least 2 more hours, because this should have worked and the fact that it didn't revealed the bug in Xcode but I just couldn't see it-

  • I tried creating a new project from the single view template and compared all of the Info.plist settings (failed).

  • I tried comparing the new project's Contents.json with mine in Images.xcassets (failed).

  • I tried dragging the images from the left sidebar Navigator into the AppIcon image wells, hoping that they were just not being copied in a build phase for some reason (failed).

  • Finally in exasperation at the thought of having to create a new project just to fix the icons, I tried deleting Images.xcassets in the left sidebar Navigator and choosing "Move to Trash", then quitting Xcode and relaunching in case it cached anything. Then when I went to click the App Icons Source popup menu, it only showed "Don't use asset catalogs". I had to select it in order to bring back the "Use Asset Catalog" button. Then I was able to create new AppIcons and LaunchImages, drag images to the wells, build and launch the app in iOS Simulator and finally see icons appear properly.

  • 我尝试了 Xcode->Product->Clean,Xcode->Window->Organizer->Projects->Derived Data->Delete...,重新启动 Xcode 和 iOS 模拟器,然后重建并重新启动应用程序(失败)。

  • 我在 iOS 模拟器中尝试了“重置内容和设置...”,甚至删除了 ~/Library/Developer/Xcode/DerivedData//Build/Products/Debug-iphoneos 并重新启动应用程序(失败)。

  • 我尝试归档该项目,希望这只是 iOS 模拟器的问题,但 Organizer-Archives 窗口中的图标仍显示为默认的带线条的白色方块,确认该图标也不会显示在设备上(当没有设备方便时使用的有用技巧)。(失败的)。

  • 我尝试在目标设置中选择“不使用资产目录”并创建一个新的 AppIcon-2 和 LaunchImage-2(失败)。 -这让我至少多花了 2 个小时,因为这应该有效,而且它没有揭示 Xcode 中的错误,但我只是看不到它-

  • 我尝试从单一视图模板创建一个新项目并比较所有 Info.plist 设置(失败)。

  • 我尝试将新项目的 Contents.json 与我在 Images.xcassets 中的进行比较(失败)。

  • 我尝试将图像从左侧边栏导航器拖到 AppIcon 图像井中,希望它们只是由于某种原因没有在构建阶段被复制(失败)。

  • 最后,一想到必须创建一个新项目来修复图标,我感到很恼火,我尝试删除左侧边栏导航器中的 Images.xcassets 并选择“移至废纸篓”,然后退出 Xcode 并重新启动以防它缓存任何内容。然后当我点击 App Icons Source 弹出菜单时,它只显示“不要使用资产目录”。我必须选择它才能恢复“使用资产目录”按钮。然后我能够创建新的 AppIcons 和 LaunchImages,将图像拖到井中,在 iOS 模拟器中构建和启动应用程序,最后看到图标正确显示。

So the problem appears to be with how Xcode stores Images.xcassets inside the project, and not with target membership, derived data, or anything in Images.xcassets itself. You must remove your assets file and create a fresh one, then drag images to wells by hand again.

因此,问题似乎在于 Xcode 如何在项目中存储 Images.xcassets,而不是目标成员资格、派生数据或 Images.xcassets 本身中的任何内容。您必须删除您的资产文件并创建一个新的资产文件,然后再次手动将图像拖到井中。

It took me 3 hours of research to solve something that should have "just worked" and the entire process of having to manually create individually sized art assets has been so tedious over the years that it has personally cost me countless hours of busywork.

我花了 3 个小时的研究才解决了一些应该“可行”的问题,而且多年来必须手动创建单独大小的艺术资产的整个过程非常乏味,以至于我个人花费了无数个小时的忙碌工作。

Hopefully this bug workaround helps someone avoid the frustration I went through. I can't help with the friction of manually sizing art assets, but I highly recommend the Icon Slayerwebsite to automate that (of which I have no affiliation).

希望这个错误解决方法可以帮助人们避免我所经历的挫折。我无法帮助手动调整艺术资产大小的摩擦,但我强烈推荐Icon Slayer网站来自动化(我没有隶属关系)。

回答by Jestin Francis

I have encountered the same problem when the project is switching from xcode5 to xcode6 . The solution is just click on the icon in the image asset,open the right panel , just tick the iOS version option in the panel,add the icons that are blank run it again ... It worked for meenter image description here

当项目从 xcode5 切换到 xcode6 时,我遇到了同样的问题。解决方案是只需单击图像资产中的图标,打开右侧面板,只需在面板中勾选 iOS 版本选项,添加空白的图标再次运行它......它对我有用在此处输入图片说明

回答by Chi-Hwa Michael Ting

I want to add my solution, where the problem is only isolated to the iPad, my app icon will not show only for iPads. After trying all the solution above, and I looked in the info.plist and found this flag that was not there before the problem with iPads. A new key/value has been added called "CFBundleIcons~ipad" without my knowledge and had nothing as it's value. Removing the key helped resolve my issue.

我想添加我的解决方案,其中问题仅与 iPad 相关,我的应用程序图标不会仅针对 iPad 显示。在尝试了上述所有解决方案后,我查看了 info.plist,发现在 iPad 出现问题之前没有这个标志。在我不知情的情况下添加了一个名为“CFBundleIcons~ipad”的新键/值,并且没有任何值。删除密钥有助于解决我的问题。

enter image description here

在此处输入图片说明

回答by Heider Sati

According to Apple Docs, the icons must be placed on the root level of the app files.

根据 Apple Docs,图标必须放置在应用程序文件的根级别。

IOS/Xcode will not go under directories to search your image.

IOS/Xcode 不会在目录下搜索您的图像。

Solution is to move the images onto the root of your application i.e. where your source files are, or you can create references in the same way.

解决方案是将图像移动到应用程序的根目录,即源文件所在的位置,或者您可以以相同的方式创建引用。

Regards Heider

问候海德

回答by Darío Gutiérrez

I had the same problem and after a couple of hours finally I could resolved it, copying an old -info.plist from one of my backups project and replace it, this works fine for me. Regards

我遇到了同样的问题,几个小时后我终于可以解决它,从我的一个备份项目中复制一个旧的 -info.plist 并替换它,这对我来说很好用。问候

回答by Mike

My issue ended up being I had used jpg images, rather than pngs.

我的问题最终是我使用了 jpg 图像,而不是 png。

回答by Chris Paveglio

For a macOS/OSX application, you also need to always add a 128 pixel size (and 2x), you can not only use a 512 pixel size and expect it to size down.

对于 macOS/OSX 应用程序,您还需要始终添加 128 像素大小(和 2x),您不仅可以使用 512 像素大小并期望它缩小大小。

回答by Arben Pnishi

If your app icon has any transparency then it won't work. Check it!

如果您的应用程序图标具有任何透明度,那么它将不起作用。核实!