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

问题描述 投票:0回答:9

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

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

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

我正在使用 XCode 7.2。

我将不胜感激任何帮助。

ios xcode xcode7
9个回答
49
投票

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


10
投票

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

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

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

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

一旦移除,清洁 - 然后 - 构建


4
投票

导致此错误的另一个原因:磁盘上的文件名大小写与

Content.json
中的文件名大小写不同。他们需要匹配。

在我的例子中,磁盘上的文件名都是小写的,这就是它们在

Content.json
中的引用方式。然后我得到了新图像,它们是大写的,我只是将它们拖到 Xcode 中来更新它们。现在 on-disk 和
Content.json
都指的是大写的文件。

但是 Git 并没有选择大小写更改,它只是认为文件已更新,并没有更改大小写。因此,在构建服务器上,我最终得到了小写的文件名,但

Content.json
指的是大写的文件名。需要在我的系统上将它们小写并修复
Content.json


0
投票

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

这可能是 XCode 的错误。


0
投票

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


0
投票

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

这是我认为我学到的:

  • 绝对 1000% 确保 Info.plist 中的内容完全匹配 Contents.json 中的内容(包括它的路径,它定义了集合的名称)并且还匹配 .csproj 文件(ItemGroup/ImageAsset)中的内容。如果您的 Info.plist 中有多次使用的文件,则仅在 .csproj 中将它们列出一次。在文本模式下编辑这些文件。复制/粘贴是你的朋友。
  • 确保 Info.plist 具有 forward 斜杠,而 .csproj 具有 back 斜杠。复制/粘贴是你的敌人。
  • 资产目录或 .csproj 中不要有额外的文件——这就是“未分配的子项”警告的来源
  • 如果您使用 Visual Studio 打开资产目录并显示任何设置不正确,请让它修复或使用它来修复,然后返回并手动编辑/验证 Content.json 和 .csproj
  • 我还把
    <key>CFBundlePackageType</key><string>APPL</string>
    并称之为
    AppIcons.appiconset
    ,尽管我不确定这两个是否重要

我将完整的 Contents.json 粘贴在下面。我从 Xamarin 示例“WatchKitCatalog”中提取它。

祝你好运。

{
  "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"
  }
}


0
投票

当图像文件名称中存在特殊字符时,我遇到了未分配子项的问题。去掉特殊字符后,问题解决了。


0
投票

在我的例子中,contents.json 中的文件名神奇地消失了。

已替换新 flutter 项目中的contents.json 文件的内容。


0
投票

最近,即使文件名和 Contents.json 具有匹配的图标名称,但使用 Xcode 构建时,似乎有一些更改和应用程序图标失败,显示以下错误:

无法为应用程序图标集写入图像数据 “AppIcon.appiconset/120.png”到 “/Users/redacted/Library/Developer/Xcode/DerivedData/Runner-gvtobjleqotxoegcxkjxrghpepal/Build/Products/Debug-iphoneos/Runner.app/[电子邮件受保护]”。

或者

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

所有以前工作的图标生成器网站都因类似错误而失败。这是唯一有效的:

图标名称:

[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]@1x.png Icon-[email protected] [email protected] [email protected]

Contents.json:

{
    "images":[
        {
            "idiom":"iphone",
            "size":"20x20",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"20x20",
            "scale":"3x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"29x29",
            "scale":"1x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"29x29",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"29x29",
            "scale":"3x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"40x40",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"40x40",
            "scale":"3x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"60x60",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"60x60",
            "scale":"3x",
            "filename":"[email protected]"
        },
        {
            "idiom":"iphone",
            "size":"76x76",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"20x20",
            "scale":"1x",
            "filename":"Icon-A[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"20x20",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"29x29",
            "scale":"1x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"29x29",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"40x40",
            "scale":"1x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"40x40",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"76x76",
            "scale":"1x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"76x76",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "idiom":"ipad",
            "size":"83.5x83.5",
            "scale":"2x",
            "filename":"[email protected]"
        },
        {
            "size" : "1024x1024",
            "idiom" : "ios-marketing",
            "scale" : "1x",
            "filename" : "[email protected]"
        }
    ],
    "info":{
        "version":1,
        "author":"redacted"
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.