5

What is the difference between Tuist init and scaffold

 3 years ago
source link: https://sarunw.com/posts/what-is-the-difference-between-tuist-init-and-scaffold/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What is the difference between Tuist init and scaffold


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.


Template

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.

sponsor-codeshot.png

What is the difference between init and scaffold

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.

How should we craft a template for init and scaffold

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.

Should a template generate Project.swift

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.

Should a template generate Tuist components

Init: Yes, if you have any helpers or config that you want to use, it is a good idea to generate it all together at the start.

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.

Should a template generate project components

Init: Yes, you might want to create boilerplate files on a new project, e.g., .gitignore and README.md. This is what you can put in the init template.

Scaffold: No, we should have that files in place already.

Should a template generate source files

Init: Yes, the template should create main app files.

Scaffold: Yes, the template should create files for new components and features.

What attributes should a template have

Init: There is not enforced by the command, but I suggest you consider having name and platform so it aligns with the official template.

Scaffold: No restriction.

Conclusion

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.


You may also like

Tuist scaffold: How to use the Tuist template to create a new module for an ongoing project

Learn how the scaffold command helps you to bootstrap new components or features such as a new VIPER module or a new framework for your new feature.

Tuist Template Scaffold Xcode Development
Tuist Template: What is it and how to create them

The template is a way to group repetitive code structure into a reusable component. You will learn how to create them in this article.

Tuist Template Xcode Development

Read more article about Tuist, Template, Scaffold, Xcode, Development,

or see all available topic

Get new posts weekly

If you enjoy this article, you can subscribe to the weekly newsletter.

Every Friday, you’ll get a quick recap of all articles and tips posted on this site — entirely for free.

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

Previous
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.

Next
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.

← Home


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK