Excluding Files from Tuist Project Target
Solving problems caused by auto generated target
GersangHelper contains core data generated by Spread Sheets. I made the project to generate data if the sheet is not contained in the target.
However Tuist add all files under the project directory into Targets automatically.
Sources
So how to exclude the files from Tuist Targets?
sources
property of Target is specified with array.
sources: ["Sources/**"],
But the type of the property is not just an array, it’s SourceFilesList.
public var sources: ProjectDescription.SourceFilesList?
It is can be created with the array of SourceFileGlob.
public static func sourceFilesList(globs: [ProjectDescription.SourceFileGlob])
And SourceFileGlob has the property to exclude paths.
So we can exclude the specific file like this.
sources: .sourceFilesList(globs: [.glob("Sources/**", excluding: ["Sources/..."])]),
Resources
However xlsx file is under the resources directory.
resources
property’s type is ResourceFileElements
public var resources: ProjectDescription.ResourceFileElements?
We can create it an array of ResourceFileElement and the Element has excluding also.
Like sources, it is possible to exclude the specific files.
resources: [.glob(pattern: "Resources/**"
,excluding: ["Resources/Models/gersanghelper.xlsx"]
)],
After regenerating, I could see the gersanghelper.xlsx execluded.
excluding
is not working without the path.
,excluding: ["gersanghelper.xlsx"]
The path is too long and I experimented the pattern instead of path, but it was not working.
,excluding: ["*gersanghelper.xlsx*"]
Conclusion
In the end, I excluded all useless files from the target.
resources: [.glob(pattern: "Resources/**"
,excluding: ["Resources/Models/gersanghelper.xlsx.secret",
"Resources/Models/gersanghelper.sqlite-shm",
"Resources/Models/gersanghelper.sqlite-wal",
"Resources/Models/gersanghelper.xlsx"]
)],
Models group now has only necessary files.
I don’t know yet how to exclude files without repeating full super paths. Please let me know with comments if you know how to do.
If you found any helpful from this post, please give it a round of applause 👏. Explore more iOS-related content in my other posts.
You can give me claps up to 50 if you keep pressing the button :)