Table of Contents
Part 4 in the series "Tuist templates and how to use them". In the final part, I want to wrap up everything by telling you my guideline on the difference between init and scaffold command, which I have a hard time figuring out when I have first known Tuist.
The template is a manifest file which use to generate files. It can be static and dynamic. Both init and scaffold commands use a template to bootstrap projects and modules. The template doesn't know which command is going to call it, so it has no such thing as a template for init or a template for scaffold.
Practical Sign in with Apple: Learn everything you need to know about Sign in with Apple to be able to integrate it in your existing app or a new one.
The only difference between the two is the purpose of using template files.
- Init command use a template to bootstrap a project from the ground.
- Scaffold uses a template for adding new features or components on existing projects.
Technically both commands can use the same template, but just because you can doesn't mean you should. You should respect the tool and be a good Tuist citizen.
Since we can use init and scaffold commands interchangeably, the only difference lies in the templates. So, the real question is how we should create a template for them. As I mentioned before, Tuist doesn't have any restrictions, but I think there are conventions that we should follow.
Init: Yes, since we use the init command to bootstrap a new project and Project.swift is a core of Tuist, your template should generate that file for users. So users can run
tuist generate and begin the development right away.
Scaffold: No, the scaffold is for an ongoing project. That's means we should already have Project.swift already.
Scaffold: No, the scaffold is mean to spawn new application components, not the project components. Generate Tuist-related components doesn't fit here. If you want to create helpers for your scaffold, you should create it manually or embed it in the init template.
Init: Yes, you might want to create boilerplate files on a new project, e.g.,
README.md. This is what you can put in the init template.
Scaffold: No, we should have that files in place already.
Init: Yes, the template should create main app files.
Scaffold: Yes, the template should create files for new components and features.
Init: There is not enforced by the command, but I suggest you consider having
platform so it aligns with the official template.
Scaffold: No restriction.
There are no real guidelines here, and these rules are just from my observation. I hope it can help you get started with Tuist and remove some confusion between these two commands.
Read more article about Tuist, Template, Scaffold, Xcode, Development, or see all available topic
Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.
If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.Become a patron Tweet Share
How to resize a SwiftUI Image and keep its aspect ratio
Learn how to use aspect fit and aspect fill content mode to fit your image to its bounds.
How to initialize @StateObject with parameters in SwiftUI
@StateObject is an essential property wrapper in SwiftUI, but I found the way to initialize them is not obvious.