R.swift icon indicating copy to clipboard operation
R.swift copied to clipboard

Check SCRIPT_OUTPUT_FILE_0 before requiring output argument

Open liamnichols opened this issue 5 years ago • 2 comments

Seeing as using the new build system (now the default in Xcode 11) requires us to declare the correct output file in the run script, I think we can avoid having to pass the output argument entirely when running the generate command?

For example, our run script is configured like so:

Screenshot 2019-12-24 at 10 39 18

Since Xcode generates the SCRIPT_OUTPUT_FILE_COUNT and SCRIPT_OUTPUT_FILE_0 environment variables when executing the run script, we could just read these directly like we do with any other environment variable?

I guess that people who continue to use the legacy build system might not be defining the output file so to account for that the generator can just fallback to previous behaviour if SCRIPT_OUTPUT_FILE_0 is missing.

The end result, would be that the run script would be as simple as rswift generate 🙂

(ps, thanks for such a great tool! I'm happy to help out on this ticket if you think its a worthwhile change)

liamnichols avatar Dec 24 '19 11:12 liamnichols

Oh ok, so digging through the code a bit more I discovered the ui testing support that will output a second generated file with different contents (just the accessibility identifiers stuff) which would make it slightly more complicated (but not impossible).

"Basic" usage could be that main.swift will take the unused output path from SCRIPT_OUTPUT_FILE_N (i.e the one not declared by --generateUITestFile) and use that in the event that outputPath is nil/isEmpty

liamnichols avatar Dec 24 '19 15:12 liamnichols

I like the idea of picking up the output file automatically, have to think a bit deeper about edge cases like generateUITestFile indeed. But less things you have to configure is better in my opinion.

mac-cain13 avatar Apr 25 '20 12:04 mac-cain13