Adding a directory into Tuist as a Reference

Lee young-jun
3 min readSep 18, 2024

--

Using set of image files in Tuist Project

I applied Tuist to my largest project. Finally I could run the app with the last article. However I found a problem when running it.

Built-in images were not loaded. Why?

Group Reference

The directory of monster images is contained in the project as reference. We can add a reference with unchecking Copy items if need

If the group is a reference, we can add it into the target

and we don’t have to add references for each image inserted. But it was necessary to put a group name on accessing the resources.

var image : UIImage?{
return UIImage(named: "monster/monster_\(self.id.description).jpg")
}

Tuist

Tuist inserts all images into the Project automatically, however we still should run generate command whenever new images added.

Tuist supports the folder reference feature to solve the issue.

So I added the folder reference into resources property in the manifest.

resources: [...,
.folderReference(path: "Resources/Images/monster")],

However the generation was failed with this error.

It seemed conflicting jpg files and images folder.

Therefore I tried to exclude the Images/monter.

resources: [.glob(pattern: "Resources/**"
,excluding: [...,
"Resources/Images/monster"
]
)
],

But this solution can’t exclude the directory. monster/ also

The pattern detects only files not directories. I had to give the pattern for files.

resources: [.glob(pattern: "Resources/**"
,excluding: [...,
"Resources/Images/monster/*"
]
)
, .folderReference(path: "Resources/Images/monster")
],

and it solved the issue.

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 :)

For additional insights and updates, check out my LinkedIn profile. Thank you for your support!

Troubleshootings

Trying to add a file at path …/gersanghelper/Projects/App/Resources/Images/monster/monster_1.jpg to a build phase that hasn’t been added to the project.

resources: [.glob(pattern: "Resources/**"
,excluding: [...,
"Resources/Images/monster/*"
]
)
, .folderReference(path: "Resources/Images/monster")
],

References

--

--

No responses yet