xcode 应用程序图标集“AppIcon”有一个未分配的子项

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

The app icon set "AppIcon" has an unassigned child

iosxcodexcode7

提问by John Cashew

I clean built my app and see this error message: The app icon set "AppIcon" has an unassigned child.

我清理构建了我的应用程序并看到此错误消息:应用程序图标集“AppIcon”有一个未分配的子项。

When I view Images.xcassets every icon slot is filled with the correct icon and there are no unassigned icons. In the past XCode seemed to randomly forget the slot for an icon and put it underneath all the labeled icon slots. On those occasions I dragged the icon back to the correct slot and the error went away. There are also no errors about any Icons being the wrong size.

当我查看 Images.xcassets 时,每个图标槽都填充了正确的图标,并且没有未分配的图标。在过去,XCode 似乎随机忘记了图标的插槽,并将其放在所有标记的图标插槽下方。在这些情况下,我将图标拖回正确的位置,错误就消失了。也没有关于任何图标大小错误的错误。

I checked Images.xcassets/AppIcon.appiconset/Contents.json and there are no entries in the JSON that have a blank filename.

我检查了 Images.xcassets/AppIcon.appiconset/Contents.json,JSON 中没有包含空白文件名的条目。

I'm using XCode 7.2.

我正在使用 XCode 7.2。

I would appreciate any help.

我将不胜感激任何帮助。

回答by Yao Li

Select the unassigned image and delete it via delete button. Clean and Build.

选择未分配的图像并通过删除按钮将其删除。清洁和建造。

回答by Jeacovy Gayle

Ran into this same error but solved it in a different way.

遇到了同样的错误,但以不同的方式解决了它。

In the project navigate to Assets.xcassets/AppIcon.appiconset/Contents.jsonand open this JSON file.

在项目中导航到 Assets.xcassets/AppIcon.appiconset/ Contents.json并打开此 JSON 文件。

Review and remove any unnecessary set of icons.

查看并删除任何不必要的图标集。

For me, it was a group of iPad icons (seeing that the application was only iPhone compatible, it was not needed).

对我来说,它是一组 iPad 图标(看到该应用程序仅与 iPhone 兼容,因此不需要)。

Once removed, Clean - then - Build

删除后,清理 - 然后 - 构建

回答by subodhk

Check if you have selected the correct image size. If it shows to put a 80x80 size image then you have to put an 80x80 size only, not less not more.

检查您是否选择了正确的图像尺寸。如果它显示要放置 80x80 尺寸的图像,那么您必须仅放置 80x80 尺寸,不能少也不能多。

回答by Eliot Gillum

I have a degree in Computer Science and I'm embarrassed to say how long I've spent on getting app icons to work for my watchOS app.

我拥有计算机科学学位,我很尴尬地说我花了多长时间让应用程序图标适用于我的 watchOS 应用程序。

Here's what I think I've learned:

以下是我认为我学到的:

  • Make absolutely 1000% sure that what's in Info.plist matches exactlywhat's in Contents.json (including the path to it, which defines the name of the set) and ALSO MATCHES what's in the .csproj file (ItemGroup/ImageAsset). If you have any files used multiple times in your Info.plist, only list them once in your .csproj. Edit these files in text mode. Copy/paste is your friend.
  • Make sure the Info.plist has forwardslashes while the .csproj has backslashes. Copy/paste is your enemy.
  • Don't have extra files in your asset directory or in your .csproj--that's where the "unassigned child" warnings come from
  • If you use Visual Studio to open your Asset Catalog and it shows anything is setup incorrectly, let it fix it or use it to fix, then go back and edit/verify the Content.json and .csproj manually
  • I also put <key>CFBundlePackageType</key><string>APPL</string>and called it AppIcons.appiconsetalthough I'm not sure either of these were important
  • 绝对 1000% 确保 Info.plist 中的内容与Contents.json 中的内容完全匹配(包括它的路径,它定义了集合的名称)并且还匹配.csproj 文件(ItemGroup/ImageAsset)中的内容。如果您在 Info.plist 中多次使用任何文件,请仅在 .csproj 中列出一次。以文本模式编辑这些文件。复制/粘贴是你的朋友。
  • 确保Info.plist的具有向前斜杠,而.csproj的有斜线。复制/粘贴是你的敌人。
  • 在您的资产目录或 .csproj 中不要有额外的文件——这就是“未分配的子项”警告的来源
  • 如果您使用 Visual Studio 打开您的资产目录并显示任何设置不正确,请修复它或使用它来修复,然后返回并手动编辑/验证 Content.json 和 .csproj
  • 我也提出<key>CFBundlePackageType</key><string>APPL</string>并调用了它,AppIcons.appiconset尽管我不确定这些是否重要

I'm pasting my full Contents.json below. I pulled it from the Xamarin sample "WatchKitCatalog."

我在下面粘贴了我的全部 Contents.json。我从 Xamarin 示例“WatchKitCatalog”中提取了它。

Godspeed and good luck to you.

祝你好运。

{
  "images": [
    {
      "scale": "1x",
      "size": "1024x1024",
      "idiom": "watch-marketing",
      "filename": "icon1024.png"
    },
    {
      "role": "notificationCenter",
      "subtype": "38mm",
      "scale": "2x",
      "size": "24x24",
      "idiom": "watch",
      "filename": "icon48.png"
    },
    {
      "role": "notificationCenter",
      "subtype": "42mm",
      "scale": "2x",
      "size": "27.5x27.5",
      "idiom": "watch",
      "filename": "icon55.png"
    },
    {
      "role": "companionSettings",
      "scale": "2x",
      "size": "29x29",
      "idiom": "watch",
      "filename": "icon58.png"
    },
    {
      "role": "companionSettings",
      "scale": "3x",
      "size": "29x29",
      "idiom": "watch",
      "filename": "icon87.png"
    },
    {
      "role": "appLauncher",
      "subtype": "38mm",
      "scale": "2x",
      "size": "40x40",
      "idiom": "watch",
      "filename": "icon80.png"
    },
    {
      "role": "appLauncher",
      "subtype": "40mm",
      "scale": "2x",
      "size": "44x44",
      "idiom": "watch",
      "filename": "Mark_NoType_SM_Trans88x88.png"
    },
    {
      "role": "appLauncher",
      "subtype": "44mm",
      "scale": "2x",
      "size": "50x50",
      "idiom": "watch",
      "filename": "Mark_NoType_SM_Trans100x100.png"
    },
    {
      "role": "quickLook",
      "subtype": "38mm",
      "scale": "2x",
      "size": "86x86",
      "idiom": "watch",
      "filename": "icon172.png"
    },
    {
      "role": "quickLook",
      "subtype": "42mm",
      "scale": "2x",
      "size": "98x98",
      "idiom": "watch",
      "filename": "icon196.png"
    },
    {
      "role": "quickLook",
      "subtype": "44mm",
      "scale": "2x",
      "size": "108x108",
      "idiom": "watch",
      "filename": "Mark_NoType_SM_Trans216x216.png"
    }
  ],
  "properties": {},
  "info": {
    "version": 1,
    "author": "xcode"
  }
}

回答by John Cashew

I noticed that 4 of the icons had a dash in their name in Content.json, but don't have a dash in their name in the Navigator or in the filesystem. I removed and readded these and the warning went away. When I readded them only 2 have the dash in Content.json.

我注意到 4 个图标在 Content.json 中的名称中有一个破折号,但在导航器或文件系统中的名称中没有破折号。我删除并阅读了这些,警告消失了。当我阅读它们时,只有 2 个在 Content.json 中有破折号。

This was probably an XCode bug.

这可能是一个 XCode 错误。