If a TargetScript
specifies an output file it is not added to the script's output files in the generated project unless it already exists at the time tuist generate
is run. Similarly, a file that does not exist at generate time is not added to the Compile Sources
phase.
My use case here is that I have a target script that runs on build, specifying its output file. The file is added to the Compile Sources
phase, and all is well: the script generates the file, so it exists by the time sources are compiled. With Tuist, this is not possible. In my own project I have hacked around it by using FileManager
to create the file prior to returning the script, but that is super fragile and can break due to project caching.
A TargetScript
requiring output files to exist to be included is definitely a bug, and in Tuist 4 is even more of a bug as files that exist are not included in output files for some reason.
For the Compile Sources
part, I believe Tuist should, or should have the option to, include files in Compile Sources
that do not exist, as it is perfectly reasonable for a script to generate those missing files.
Sample projects:
tuist3.zip
tuist4.zip
tuist generate
on the attached sample tuist3.zip
TuistScriptOutputFiles
target, and expand the Touch File.swift for TuistScriptOutputFiles
phase under Build PhasesOutput Files
is emptyCompile Sources
under Build PhasesFile.swift
is not includedtuist generate
againOutput Files
is no longer emptyFile.swift
is now included in Compile Sources
phasetuist generate
on the attached sample tuist4.zip
TuistScriptOutputFiles
target, and expand the Touch File.swift for TuistScriptOutputFiles
phase under Build PhasesOutput Files
is emptyCompile Sources
under Build PhasesFile.swift
is not includedtuist generate
againOutput Files
is still emptyFile.swift
is now included in Compile Sources
phaseNo errors
14.3.1
3.42.3, 4.1.2
15.2
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too