Swiftgen: Multiple asset catalogs - no image found

Created on 21 Nov 2016  ·  12Comments  ·  Source: SwiftGen/SwiftGen

I have multiple asset catalogs in my project. If I run swiftgen images $PROJECT_DIR I get the output no image found.

If I explicitly specify an asset catalog, Swiftgen will output code, however when I run multiple swiftgen images commands, even if I use --enumName I still get build failures (Invalid redeclaration of Image).

Swiftgen happily handled multiple asset catalogs in the past (albeit flattened into a single enum), so I assume this is a bug introduced with the actool change?

WIP enhancement

All 12 comments

That's right, now that swiftgen don't parse directories in the filesystem for images but a specific assets catalog that's why you now have only one assets catalog output at once… and running it multiple times, given that the template generates a typealias Image= UIImage each times, that explains the compiler error you have.

Until we fix this you can duplicate the images template (swiftgen templates cat images-swift3 >images-notypealias.stencil or whatever images template you're using), remove the typealias declaration from your copy, then use that template (with --templatePath) for all asset catalogs except the first one.

I don't know what's the best way we will come up to fix that. Probably reintroduce the ability to specify a directory to parse, even if that will now look for all asset catalogs in that directory and still use actool to parse each one…? (cc @djbe)

Okay, thanks Olivier. I’d expect if your Swiftgenning one asset catalog, most of the time you’ll want to do them all, and see them namespaced somehow?

I might just consolidate into a single set if this is not well supported.

Damn, sorry we missed that use case.

I'm thinking more along the lines of #33, where you provide multiple path values. Recursively parsing a whole folder structure is far from ideal, it's better if you tell swiftgen where to look.

I'll take a look at this after #206, as there'd be too much overlap otherwise.

This is to be confirmed with @kylef (and @plivesey who has probably asked him already for another feature he's working on) but iirc, Commander doesn't support specifying the same flag multiple times 😢
So except if we fork and PR Commander to add this feature (which would be great), so far there's no way to specify multiple --path values just yet.

Another workaround would be to accept a single param with all the paths concatenated and separated with e.g. a comma, but that would not seen pretty to me, so I'd prefer a PR on Commander for that instead 😉

PR Commander it is then 😆

PR created, but I'd like to note that there's already a VariadicArgument to receive multiple path values. It's just the options that were limited to 1 value.

I'm going to wait until #201 (and maybe #206) is merged, and Commander 0.6 is released before doing this, but soon 😄

I'll probably tackle #33 while I'm at it.

@djbe Did you ask Kyle if he has a rough estimate of when Commander 0.6 is gonna be out? I mean, if he's quite busy and won't have time to do a release soon we might as well either find an alternate way in the meantime, or depend on your fork of Commander until it's merged?

Hmmm no I didn't. 5 days ago he mentioned doing a release that night, so... yeah, maybe depend on the fork.

I have some local stashes/diffs prepared for this, but it'd be easier if we could merge #212 otherwise it'll be conflict bonanza.

https://github.com/kylef/Commander/releases/tag/0.6.0 🎈. Thanks for all the PRs here @djbe.

Yay 🎉 Thx @kylef !

@djbe now that #212 is merged and Commander 0.6 is out, you should be able to apply your stashes to fix that 👍 (then I think I can find some time during the week to do a release with that)

213 has been merged, which fixes this. A release will probably happen later, once we've merged some more PRs, but for now you can check out the project and build it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bengilroy picture bengilroy  ·  3Comments

SummerHF picture SummerHF  ·  3Comments

djbe picture djbe  ·  6Comments

BastiaanAndriessen picture BastiaanAndriessen  ·  4Comments

valerianb picture valerianb  ·  7Comments