Swiftgen: Images command fails for some type of assets

Created on 7 Dec 2016  ·  13Comments  ·  Source: SwiftGen/SwiftGen

SwiftGen 4.0.1
I haven't debugged this any further, but creating a issue anyways just FYI...

$ swiftgen images -t swift3 resources/Assets.xcassets/ > Sources/swiftgen/Image.swift
2016-12-07 11:24:43.729 ibtoold[70092:1067958] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEInterfaceBuilder/IDEInterfaceBuilder-11542/Foundation/Utilities/IBFoundationAdditions.m:199
Details:  +[IBICSlot orderedComponentClasses] is expected to override abstract method from base class.
Function: void IBAbstractMethodHelper(__strong id, SEL)
Thread:   <NSThread: 0x7f8d3060bdc0>{number = 1, name = main}
Hints: None
Backtrace:
  0   -[DVTAssertionHandler handleFailureInFunction:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
  1   _DVTAssertionHandler (in DVTFoundation)
  2   _DVTAssertionFailureHandler (in DVTFoundation)
  3   IBAbstractMethodHelper (in IBFoundation)
  4   +[IBICSlot orderedComponentClasses] (in IBFoundation)
  5   -[IBICSlottedAssetCollection(DisplayAdditions) populatePlistWithDescriptionForIctool:forChild:] (in IDEInterfaceBuilderKit)
  6   -[IBICAbstractCatalogItem(DisplayAdditions) plistDescriptionForIctool] (in IDEInterfaceBuilderKit)
  7   -[IBICAbstractCatalogItem(DisplayAdditions) plistDescriptionForIctool] (in IDEInterfaceBuilderKit)
  8   -[IBICAbstractCatalogItem(DisplayAdditions) plistDescriptionForIctool] (in IDEInterfaceBuilderKit)
  9  0x000000010a38b9e3 (in ibtoold)
 10  0x000000010a38c64e (in ibtoold)
 11  0x000000010a38cc9f (in ibtoold)
 12  0x000000010a39b3f0 (in ibtoold)
 13  0x000000010a39ba91 (in ibtoold)
 14  0x000000010a39b964 (in ibtoold)
 15  0x000000010a389c2b (in ibtoold)
 16  0x000000010a39afeb (in ibtoold)
 17  0x000000010a39a0a2 (in ibtoold)
 18   start (in libdyld.dylib)
Apple bug

Most helpful comment

All 13 comments

🤔 Strange that the swiftgen images command crashes in ibtoold… I mean, we use actool, but not ibtool so wonder why it would be called, except if actool internally depends on ibtool

What version of Xcode are you using (especially which one is set as default for command line in your xcode-select -p)?

Can you try running xcrun actool --print-contents resources/Assets.xcassets/ in your terminal and see if the crash still occurs?

This crash being inside ibtool itself, I think something is wrong and crashes actool or ibtool internally (you might want to report a bug to Apple btw), maybe something is misconfigured in your asset catalog… if there's nothing secret, feel free to share your asset catalog so we can test on it.

Given the crash printed by ibtool/actool my guess is that you have some unassigned entry in your asset catalog, like misplaced image not associated with any slot, or a slot with an invalid identifier for the hardware it's associated to, or something similar?

What version of Xcode are you using (especially which one is set as default for command line in your xcode-select -p)?

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
$ xcodebuild -version
Xcode 8.1
Build version 8B62

Can you try running xcrun actool --print-contents resources/Assets.xcassets/ in your terminal and see if the crash still occurs?

$ xcrun actool --print-contents resources/Assets.xcassets/
2016-12-08 09:43:52.447 ibtoold[55214:1977094] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEInterfaceBuilder/IDEInterfaceBuilder-11542/Foundation/Utilities/IBFoundationAdditions.m:199
Details:  +[IBICSlot orderedComponentClasses] is expected to override abstract method from base class.
Function: void IBAbstractMethodHelper(__strong id, SEL)
Thread:   <NSThread: 0x7fbd91f02540>{number = 1, name = main}
Hints: None
Backtrace:
  0   -[DVTAssertionHandler handleFailureInFunction:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
  1   _DVTAssertionHandler (in DVTFoundation)
  2   _DVTAssertionFailureHandler (in DVTFoundation)
  3   IBAbstractMethodHelper (in IBFoundation)
  4   +[IBICSlot orderedComponentClasses] (in IBFoundation)
  5   -[IBICSlottedAssetCollection(DisplayAdditions) populatePlistWithDescriptionForIctool:forChild:] (in IDEInterfaceBuilderKit)
  6   -[IBICAbstractCatalogItem(DisplayAdditions) plistDescriptionForIctool] (in IDEInterfaceBuilderKit)
  7   -[IBICAbstractCatalogItem(DisplayAdditions) plistDescriptionForIctool] (in IDEInterfaceBuilderKit)
  8   -[IBICAbstractCatalogItem(DisplayAdditions) plistDescriptionForIctool] (in IDEInterfaceBuilderKit)
  9  0x0000000104a749e3 (in ibtoold)
 10  0x0000000104a7564e (in ibtoold)
 11  0x0000000104a75c9f (in ibtoold)
 12  0x0000000104a843f0 (in ibtoold)
 13  0x0000000104a84a91 (in ibtoold)
 14  0x0000000104a84964 (in ibtoold)
 15  0x0000000104a72c2b (in ibtoold)
 16  0x0000000104a83feb (in ibtoold)
 17  0x0000000104a830a2 (in ibtoold)
 18   start (in libdyld.dylib)

feel free to share your asset catalog so we can test on it.

Sorry but it's confidential I'm afraid..

I created minimum project to reproduce.
https://github.com/toshi0383/SwiftGen-Assets-Sample

The issue reproduces sometimes, sometime it doesn't.
Please try with this command.

for i in `seq 0 9`; do swiftgen images -t swift3 AssetsTest/Assets.xcassets/ > /dev/null ;done

First of all it's weird that SwiftGen says "// No image found" even when it didn't crash.
If I remove the "App Icon & Top Shelf Image" asset, it works as expected.

As you've probably noticed, we depend on actool for parsing asset catalogs, which is also used by Xcode to compile them. It seems to have some trouble with tvOS assets, and only sometimes crashes for some reason. The other times it just doesn't output anything...

Quick question: does this asset catalog actually compile? I keep trying here, but can't find the valid platform name for tvOS:
xcrun actool --compile test AssetsTest/Assets.xcassets --minimum-deployment-target 10.0 --platform SOMETHING

Maybe try with xcrun -sdk appletvos actool --print-contents … instead?
(You can use xcodebuild -showsdks to list the possible SDK names)

I'm using Xcode 8.1 build 8B62 too
I tried for i inseq 0 50; do echo $i; xcrun actool --print-contents AssetsTest/Assets.xcassets/; done on the sample project you provided
I had to run this for loop 3 times to see a crash only at the 49th iteration of the 3rd try (so after the 149th iteration)…

Definitely worth filing a radar to Apple as this is definitely a random bug with actool/ibtool, but will keep investigating to see if we could imagine a workaround…

@djbe I've tried to run xcrun actool --compile test AssetsTest/Assets.xcassets --minimum-deployment-target 10.0 --platform appletvos multiple times, and it compiles (well, once I've quit my Xcode-8.2b2.app that I had open, because otherwise it prevents actool to pilot the 8.1 simulator to create a SimDevice as it fails to communicate with the simulator being open by 8.2… but I have no idea why it tries to communicate with the simulator just to list the assets catalog content…)

Bad news, I've switched my xcode-select to Xcode 8.2b2 instead of Xcode 8.1 and for i in $(seq 0 50); do echo $i; xcrun actool --print-contents AssetsTest/Assets.xcassets/; done fails _more_ often than with 8.2 😢 Didn't try the latest betas yet.

Right, so I tried adding some stuff to an empty catalog:

  • Image set _works_
  • Data set _works_
  • Texture set crashes
  • Cube Texture set crashes
  • App Icons and Launch Images:

    • iOS App Icon & Launch Images _works_

    • macOS App Icon & Generic Icon _works_

    • watchOS App Icon _works_

    • tvOS:

    • Launch Image _works_

    • App icon and top shelf image crashes

  • Watch Complication crashes
  • Apple TV Image Stack & Image Stack Layer _works_
  • Sprite Atlas _works_
  • Game Center (Dashboard, Leaderboard & Leaderboard Set) _works_
  • Sticker Pack (Pack, Sticker, Sequence and Sequence Frame) _works_

Note: when I say "crashes", I actually mean "no output or crashes".

Not that it matters now we've removed the actool dependency in #43, but I just spoke to an Apple engineer at WWDC and he said this is fixed in Xcode 9. I also tested it in the beta and does indeed seem to work

Ugh. Anyway, we still need to support older Xcode versions, and it might break again, so 🤷‍♂️

Ahah thx for the update!
They really did fix all the dev tools this year! 🎊

Was this page helpful?
0 / 5 - 0 ratings

Related issues

taykay08 picture taykay08  ·  3Comments

danielsaidi picture danielsaidi  ·  7Comments

kacper1703 picture kacper1703  ·  3Comments

drjasonharrison picture drjasonharrison  ·  5Comments

razor313 picture razor313  ·  6Comments