Swiftgen: Error: File Generated not found

Created on 15 Aug 2018  Â·  8Comments  Â·  Source: SwiftGen/SwiftGen

As the title says, I am running Xcode 10 beta 6 and this is my configuration:

strings:
  paths:
    - Tweetometer/en.lproj/Localizable.strings
  templateName: structured-swift4
  output: Generated/LocalizedStrings.swift
xcassets:
  paths:
    - Tweetometer/Assets.xcassets
  templateName: swift4
  output: Generated/Images.swift

When running as a run script phase or via the command-line the errors is: File Generated not found.

I assume that an error occurs and the file is not generated in the correct folder?

question

All 8 comments

Pretty sure this is unrelated to swift 4.2.
Just to make sure: Does the Generated folder exist?

Yes, I created the folder manually. I also tried removing strings and xcassets but it seems that both are the cause of the issue here.

All relative paths specified in the configuration file (input_dir, output_dir, inputs, templatePath, output) are relative to the location of the configuration file itself.

Are you sure you got those relative paths right?

Here's an example with both the input and output dirs:
https://github.com/appwise-labs/AppwiseCore-Example/blob/master/swiftgen.yml

Oh yeah, I was missing output: Tweetometer/Generated/Images.swift. Shouldn't the Generated folder be created automatically if not present though? This issue can be closed in any case, thanks for the help!

The missing intermediate folders are not created automatically if not present indeed. That's a choice I made to avoid anyone who messed their configuration file and used wrong relative path accidentally (like you did 😜) to create folders and files in the wrong place accidentally.

I preferred for the user to have an error message, and thus letting them know clearly that the path they configured was not what they expected, and have a failure exit code (making the build fail too in case you use SwiftGen as a build phase)… over silently creating the output in the wrong place, and potentially creating/updating a file at one place while the Xcode project was using another file (potentially created earlier before the user decided to update the paths) that would have never been updated, and thus would be out of sync, without reporting any error to the user about it.

We could change that decision, and create intermediate folders automatically if they don't exist, but I think failing with an error is better than letting the user think the file they are compiling is updated while in fact another one in another location is created/updated instead.

One change that we could do though could be to print the full path of the missing file/folder in that error message, instead of the relative path only.

Yeah, let's avoid randomly creating a bunch of folders somewhere. A more descriptive error message might be the ticket in this case.

I understand not creating intermediate folders as a default, although it would be nice to have it as an option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filip-zielinski picture filip-zielinski  Â·  3Comments

kacper1703 picture kacper1703  Â·  3Comments

BastiaanAndriessen picture BastiaanAndriessen  Â·  4Comments

bengilroy picture bengilroy  Â·  3Comments

jrmybrault picture jrmybrault  Â·  7Comments