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

rbl8hiat  于 2023-11-21  发布在  其他
关注(0)|答案(9)|浏览(210)

我清理构建了我的应用程序,看到这个错误消息:应用程序图标集“AppIcon”有一个未分配的孩子。
当我查看Images.xcassets时,每个图标槽都被正确的图标填充,并且没有未分配的图标。在过去,XCode似乎随机忘记了图标的槽,并将其放在所有标记的图标槽下面。在那些情况下,我将图标拖回正确的槽,错误就消失了。也没有任何关于图标大小错误的错误。
我检查了Images.xcassets/AppIcon.appiconset/Contents.json,JSON中没有文件名为空的条目。
使用Xcode 7.2
我将感激任何帮助。

jhdbpxl9

jhdbpxl91#

选择未分配的图像,并通过删除按钮删除它。

cuxqih21

cuxqih212#

遇到了同样的错误,但以不同的方式解决了它。
在项目中,导航到Assets.xcassets/AppIcon.appiconset/Contents.json并打开此JSON文件。
查看并删除任何不必要的图标集。
对我来说,这是一组iPad图标(看到应用程序只兼容iPhone,不需要)。
一旦删除,清洁-然后-建立

bvjveswy

bvjveswy3#

这个错误的另一个原因是:磁盘上的文件名大小写和Content.json中的文件名大小写不同。它们需要匹配。
在我的例子中,磁盘上的文件名都是小写的,这就是它们在Content.json中被引用的方式。然后我得到了新的图像,它们被升级,我只是把它们拖到Xcode中来更新它们。现在磁盘上和Content.json都引用了升级的文件。
但是Git并没有选择大小写,它只是认为文件更新了,并没有改变大小写。所以在构建服务器上,我最终使用了小写的文件名,但是Content.json引用了大写的文件名。需要在我的系统上将它们小写并修复Content.json

n1bvdmb6

n1bvdmb64#

我注意到其中4个图标在Content.json中的名称中有一个破折号,但在Navigator或文件系统中的名称中没有破折号。我删除并重新添加了这些图标,警告消失了。当我重新添加它们时,只有2个图标在Content.json中有破折号。
这可能是一个Xcode bug。

pcww981p

pcww981p5#

检查您是否选择了正确的图像大小。如果它显示放一个80x80大小的图像,那么你必须只放一个80x80大小,而不是更少。

ecbunoof

ecbunoof6#

我有计算机科学学位,我很不好意思说我花了多长时间让应用程序图标为我的watchOS应用程序工作。
我觉得我学到了:

  • 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,虽然我不确定这两个是否重要。

我把完整的Contents.json粘贴在下面。我从Xamarin示例“WatchKitCatalog”中提取了它。
祝你好运

  1. {
  2. "images": [
  3. {
  4. "scale": "1x",
  5. "size": "1024x1024",
  6. "idiom": "watch-marketing",
  7. "filename": "icon1024.png"
  8. },
  9. {
  10. "role": "notificationCenter",
  11. "subtype": "38mm",
  12. "scale": "2x",
  13. "size": "24x24",
  14. "idiom": "watch",
  15. "filename": "icon48.png"
  16. },
  17. {
  18. "role": "notificationCenter",
  19. "subtype": "42mm",
  20. "scale": "2x",
  21. "size": "27.5x27.5",
  22. "idiom": "watch",
  23. "filename": "icon55.png"
  24. },
  25. {
  26. "role": "companionSettings",
  27. "scale": "2x",
  28. "size": "29x29",
  29. "idiom": "watch",
  30. "filename": "icon58.png"
  31. },
  32. {
  33. "role": "companionSettings",
  34. "scale": "3x",
  35. "size": "29x29",
  36. "idiom": "watch",
  37. "filename": "icon87.png"
  38. },
  39. {
  40. "role": "appLauncher",
  41. "subtype": "38mm",
  42. "scale": "2x",
  43. "size": "40x40",
  44. "idiom": "watch",
  45. "filename": "icon80.png"
  46. },
  47. {
  48. "role": "appLauncher",
  49. "subtype": "40mm",
  50. "scale": "2x",
  51. "size": "44x44",
  52. "idiom": "watch",
  53. "filename": "Mark_NoType_SM_Trans88x88.png"
  54. },
  55. {
  56. "role": "appLauncher",
  57. "subtype": "44mm",
  58. "scale": "2x",
  59. "size": "50x50",
  60. "idiom": "watch",
  61. "filename": "Mark_NoType_SM_Trans100x100.png"
  62. },
  63. {
  64. "role": "quickLook",
  65. "subtype": "38mm",
  66. "scale": "2x",
  67. "size": "86x86",
  68. "idiom": "watch",
  69. "filename": "icon172.png"
  70. },
  71. {
  72. "role": "quickLook",
  73. "subtype": "42mm",
  74. "scale": "2x",
  75. "size": "98x98",
  76. "idiom": "watch",
  77. "filename": "icon196.png"
  78. },
  79. {
  80. "role": "quickLook",
  81. "subtype": "44mm",
  82. "scale": "2x",
  83. "size": "108x108",
  84. "idiom": "watch",
  85. "filename": "Mark_NoType_SM_Trans216x216.png"
  86. }
  87. ],
  88. "properties": {},
  89. "info": {
  90. "version": 1,
  91. "author": "xcode"
  92. }
  93. }

字符串

展开查看全部
zazmityj

zazmityj7#

当图像文件的名称中有特殊字符时,我遇到了未分配孩子的问题。在删除特殊字符后,问题得到了解决。

mm5n2pyu

mm5n2pyu8#

在我的例子中,contents.json的文件名神奇地消失了。
已经从一个新的flutter项目中替换了contents.json文件的内容。

gkn4icbw

gkn4icbw9#

看起来有一些变化,应用图标在使用Xcode构建时失败,最近显示以下错误,即使文件名和Contents.json具有匹配的图标名称:
无法将从“AppIcon.appiconset/120.png”设置的应用图标的图像数据写入“/Users/redacted/Library/Developer/Xcode/DerivedData/Runner-gvaporjleqotxoegcxkjxrghpepal/Build/Products/Redig-iphoneos/Runner.app/ email protected(https://stackoverflow.com/cdn-cgi/l/email-protection)“。

应用图标集“AppIcon”有一个未分配的子项
所有以前的工作图标生成器网站失败与类似的错误.这是唯一一个工程:
图标名称:

  1. [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:

  1. {
  2. "images":[
  3. {
  4. "idiom":"iphone",
  5. "size":"20x20",
  6. "scale":"2x",
  7. "filename":"[email protected]"
  8. },
  9. {
  10. "idiom":"iphone",
  11. "size":"20x20",
  12. "scale":"3x",
  13. "filename":"[email protected]"
  14. },
  15. {
  16. "idiom":"iphone",
  17. "size":"29x29",
  18. "scale":"1x",
  19. "filename":"[email protected]"
  20. },
  21. {
  22. "idiom":"iphone",
  23. "size":"29x29",
  24. "scale":"2x",
  25. "filename":"[email protected]"
  26. },
  27. {
  28. "idiom":"iphone",
  29. "size":"29x29",
  30. "scale":"3x",
  31. "filename":"[email protected]"
  32. },
  33. {
  34. "idiom":"iphone",
  35. "size":"40x40",
  36. "scale":"2x",
  37. "filename":"[email protected]"
  38. },
  39. {
  40. "idiom":"iphone",
  41. "size":"40x40",
  42. "scale":"3x",
  43. "filename":"[email protected]"
  44. },
  45. {
  46. "idiom":"iphone",
  47. "size":"60x60",
  48. "scale":"2x",
  49. "filename":"[email protected]"
  50. },
  51. {
  52. "idiom":"iphone",
  53. "size":"60x60",
  54. "scale":"3x",
  55. "filename":"[email protected]"
  56. },
  57. {
  58. "idiom":"iphone",
  59. "size":"76x76",
  60. "scale":"2x",
  61. "filename":"[email protected]"
  62. },
  63. {
  64. "idiom":"ipad",
  65. "size":"20x20",
  66. "scale":"1x",
  67. "filename":"[email protected]"
  68. },
  69. {
  70. "idiom":"ipad",
  71. "size":"20x20",
  72. "scale":"2x",
  73. "filename":"[email protected]"
  74. },
  75. {
  76. "idiom":"ipad",
  77. "size":"29x29",
  78. "scale":"1x",
  79. "filename":"[email protected]"
  80. },
  81. {
  82. "idiom":"ipad",
  83. "size":"29x29",
  84. "scale":"2x",
  85. "filename":"[email protected]"
  86. },
  87. {
  88. "idiom":"ipad",
  89. "size":"40x40",
  90. "scale":"1x",
  91. "filename":"[email protected]"
  92. },
  93. {
  94. "idiom":"ipad",
  95. "size":"40x40",
  96. "scale":"2x",
  97. "filename":"[email protected]"
  98. },
  99. {
  100. "idiom":"ipad",
  101. "size":"76x76",
  102. "scale":"1x",
  103. "filename":"[email protected]"
  104. },
  105. {
  106. "idiom":"ipad",
  107. "size":"76x76",
  108. "scale":"2x",
  109. "filename":"[email protected]"
  110. },
  111. {
  112. "idiom":"ipad",
  113. "size":"83.5x83.5",
  114. "scale":"2x",
  115. "filename":"[email protected]"
  116. },
  117. {
  118. "size" : "1024x1024",
  119. "idiom" : "ios-marketing",
  120. "scale" : "1x",
  121. "filename" : "[email protected]"
  122. }
  123. ],
  124. "info":{
  125. "version":1,
  126. "author":"redacted"
  127. }
  128. }

展开查看全部

相关问题