17

When building an app via XCode 8, running the application on Mavericks (OSX 10.9), I receive a crash with the following error:

Crash stack

Apple does specifically mention this in the XCode 8 Release notes with the following details:

Asset Catalogs

Applications compiled with Xcode 8 and a deployment target of iOS 7 may crash at launch with the following assertion:

Assertion failed: (maxCountIncludingZeroTerminator > 0 && tokenCount < maxCountIncludingZeroTerminator), function CUIRenditionKeyCopy, file /SourceCache/CoreUI/CoreUI-232.4/CoreTheme/ThemeStorage/CUIThemeRendition.m, line 185.

To work around this issue, update the deployment target to iOS 8.0 or higher, or add a single image to the asset catalog that has at least five attributes specified across the image set, such as:

  • scale (1x, 2x, 3x)
  • idiom (add iPad,iPhone, and a universal asset)
  • direction (left to right, right to left)
  • width/height class (any & compact, and so forth)
  • memory (add a 1 GB asset)
  • graphics (add a Metal 1v2 asset)

It is not necessary to use the image in your code or to add all of these attributes. (27852391)

I've tried adding some 3x scaled images to the project, however I still receive the same exception. According to the documentation I only need to add one of those attributes to resolve the issue, however it does not seem to do the trick for me. Has anyone else run into this? Does anyone have any resolution?

Community
  • 1
  • 1
Kyle
  • 17,317
  • 32
  • 140
  • 246

2 Answers2

16

I created a new icon and manually modified the json file to contain the following:

{
  "images" : [
    {
      "idiom" : "universal",
      "filename" : "apple-17.png",
      "language-direction" : "right-to-left",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-18.png",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-39.png",
      "language-direction" : "right-to-left",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-38.png",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-48.png",
      "language-direction" : "right-to-left",
      "scale" : "3x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-49.png",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "scale" : "3x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-19.png",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-20.png",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-37.png",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-36.png",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-50.png",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "3x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-51.png",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "3x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-21.png",
      "width-class" : "regular",
      "language-direction" : "right-to-left",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-22.png",
      "width-class" : "regular",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-35.png",
      "width-class" : "regular",
      "language-direction" : "right-to-left",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-34.png",
      "width-class" : "regular",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-52.png",
      "width-class" : "regular",
      "language-direction" : "right-to-left",
      "scale" : "3x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-53.png",
      "width-class" : "regular",
      "graphics-feature-set" : "metal1v2",
      "language-direction" : "right-to-left",
      "scale" : "3x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-23.png",
      "width-class" : "regular",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "1x"
    },
    {
      "language-direction" : "right-to-left",
      "graphics-feature-set" : "metal1v2",
      "idiom" : "universal",
      "width-class" : "regular",
      "filename" : "apple-16.png",
      "height-class" : "regular",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-33.png",
      "width-class" : "regular",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "2x"
    },
    {
      "language-direction" : "right-to-left",
      "graphics-feature-set" : "metal1v2",
      "idiom" : "universal",
      "width-class" : "regular",
      "filename" : "apple-32.png",
      "height-class" : "regular",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "apple-54.png",
      "width-class" : "regular",
      "language-direction" : "right-to-left",
      "height-class" : "regular",
      "scale" : "3x"
    },
    {
      "language-direction" : "right-to-left",
      "graphics-feature-set" : "metal1v2",
      "idiom" : "universal",
      "width-class" : "regular",
      "filename" : "apple-55.png",
      "height-class" : "regular",
      "scale" : "3x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}

I do not actually use this icon anywhere. This sorted the issue. I have uploaded the icon here if anyone runs into this issue and needs it.

Kyle
  • 17,317
  • 32
  • 140
  • 246
  • Thank you very much for posting this question and solution. – DDP Oct 04 '16 at 05:34
  • I have followed this solution but it still crashes Assertion failed: (tokenCount < maxCountIncludingZeroTerminator - 1), function CUIRenditionKeySetValueForAttribute, file /SourceCache/CoreUI/CoreUI-231.1/CoreTheme/ThemeStorage/CUIThemeRendition.m, line 136. Any solutions? – mKane Oct 26 '16 at 17:50
  • Try downloading the iconFix.zip file again. I just made an update to it and my original answer. – Kyle Oct 26 '16 at 18:10
  • Thanks for this; I didn't want to require 10.10 if I didn't have to. – Wevah Nov 15 '16 at 08:20
  • @Kyle +1 I had the same issue. I added your file and it seems to work. Do I have to add it to all of my asset catalogs or only to one? – Tibidabo Dec 09 '16 at 02:19
  • @Tibidabo Just to one I believe. I made a separate asset catalog just for this fix. – DDP Dec 09 '16 at 07:08
  • @Kyle thanks, it makes sense as they all end up in a single file in the bundle – Tibidabo Dec 09 '16 at 09:38
  • @Kyle I downloaded the `IconFix.zip` file which contains a folder named `Mavericks10.9.imageset`. Do I just drag the imageset folder into my Xcode project then resubmit the app to the App Store? – wigging Apr 13 '17 at 03:08
  • Why did you add 24 images if all that the workaround requires is adding single images with 5 attributes? See also http://stackoverflow.com/a/39840120/15809 – Mecki Apr 28 '17 at 16:23
  • @Mecki when I only specified five attributes, xcode was messing with them automatically and it stopped working. Specifying these 24 ensured it worked and xcode no longer messes with the files. – Kyle May 04 '17 at 15:13
  • This worked for me. Thanks. Just drag and drop imageset folder inside asset catalogue on Xcode editor. (D&D on the left pane where you usually add images in asset catalogue.) – user5865651 Jan 28 '18 at 11:59
3

In my testing (also targetting macOS 10.9), this only occurred when building with Xcode 8 on macOS 10.12.

The crash at launch did not occur when building with Xcode 8 on macOS 10.11.6.

This might represent a quick work-around for some people, although Kyle's answer is definitive as per the Xcode release notes. (I have not tested Xcode 8.1beta).

Update

Building with Xcode 8.1b2 on macOS 10.12, the behaviour is the same as with Xcode 8.0. (Next test will be building on the 10.12.1 beta)

DDP
  • 2,463
  • 1
  • 26
  • 28
  • I had the same issue, I updated my apps for Touchbar and now they all crashing on 10.12.1 Kyle solution seems to work so far. – Tibidabo Dec 09 '16 at 02:22