Today I’m exploring Tuist - A project generation tools for Xcode projects. It’s a tool similar to Xcodegen or if you have a background in backend programming, you can see it as anInfrastructure as Code tool.

One of the biggest selling points of this project aside from not having to deal with the dreaded .xcodeproj conflicts is that it uses Swift to define project generation. I feel like it will help your team to easily adopt it.

Anyway, this blog post is just to document my process of learning Tuist. I have no prior experience using it in a personal or team settings.

Installation

The installation process is seamless and fast. I only have to run the following command to set tuist up.

1$~ bash <(curl -Ls https://install.tuist.io)

Project generation

Following the docs, I set up my first project. I need to create an empty directory first and run the following command:

1tuist init --platform ios

This will bootstrap files necessary to create an iOS application. Running tree, it will show the following directory structure

 1.
 2├── Project.swift
 3├── Targets
 4│   ├── TuistApp
 5│   │   ├── Resources
 6│   │   │   └── LaunchScreen.storyboard
 7│   │   ├── Sources
 8│   │   │   └── AppDelegate.swift
 9│   │   └── Tests
10│   │       └── AppTests.swift
11│   ├── TuistAppKit
12│   │   ├── Sources
13│   │   │   └── TuistAppKit.swift
14│   │   └── Tests
15│   │       └── TuistAppKitTests.swift
16│   └── TuistAppUI
17│       ├── Sources
18│       │   └── TuistAppUI.swift
19│       └── Tests
20│           └── TuistAppUITests.swift
21└── Tuist
22    ├── Config.swift
23    └── ProjectDescriptionHelpers
24        └── Project+Templates.swift
25
2613 directories, 10 files

Project.swift is where I have to define your project descriptions. Right now, I still can’t run the project yet. To do that, I need to run the following commands.

1$~ tuist generate

This will generate the .xcodeproj, .xcworkspace, and Derived/ files necessary to run the project.

 1.
 2├── Derived
 3│   ├── InfoPlists
 4│   │   ├── TuistApp.plist
 5│   │   ├── TuistAppKit.plist
 6│   │   ├── TuistAppKitTests.plist
 7│   │   ├── TuistAppTests.plist
 8│   │   ├── TuistAppUI.plist
 9│   │   └── TuistAppUITests.plist
10│   └── Sources
11│       └── Bundle+TuistApp.swift
12├── Project.swift
13├── Targets
14│   ├── TuistApp
15│   │   ├── Resources
16│   │   │   └── LaunchScreen.storyboard
17│   │   ├── Sources
18│   │   │   └── AppDelegate.swift
19│   │   └── Tests
20│   │       └── AppTests.swift
21│   ├── TuistAppKit
22│   │   ├── Sources
23│   │   │   └── TuistAppKit.swift
24│   │   └── Tests
25│   │       └── TuistAppKitTests.swift
26│   └── TuistAppUI
27│       ├── Sources
28│       │   └── TuistAppUI.swift
29│       └── Tests
30│           └── TuistAppUITests.swift
31├── Tuist
32│   ├── Config.swift
33│   └── ProjectDescriptionHelpers
34│       └── Project+Templates.swift
35├── TuistApp.xcodeproj
36│   ├── project.pbxproj
37│   ├── project.xcworkspace
38│   │   └── contents.xcworkspacedata
39│   └── xcshareddata
40│       ├── xcdebugger
41│       └── xcschemes
42│           ├── TuistApp.xcscheme
43│           ├── TuistAppKit.xcscheme
44│           ├── TuistAppKitTests.xcscheme
45│           ├── TuistAppTests.xcscheme
46│           ├── TuistAppUI.xcscheme
47│           └── TuistAppUITests.xcscheme
48└── TuistApp.xcworkspace
49    ├── contents.xcworkspacedata
50    └── xcshareddata
51        └── xcschemes
52            └── TuistApp-Project.xcscheme
53
5424 directories, 27 files

Editing Project.swift

I find editing Project.swift directly with a text editor like VSCode difficult since I couldn’t figure out the APIs definitions. Going through the docs apparently, there’s a command to help this process. You can run the followings

1$~ tuist edit

This will open a temporary Xcode project and you can utilize the Xcode auto-completion to write the project’s description.

Conclusions

However, right now I couldn’t figure out why the projects are structured the way it is(ie. TuistApp/, TuistAppKit, TuistAppUI). I feel like maybe it has something to do with µFeatures Architecture define in the docs. I tried to customize the project description following the examples given but it doesn’t exactly generate new files like the initial setup either. Maybe I need to use tuist scaffold for that.

I feel like the best way to figure out how to use it is by migrating an existing project that I have to use Tuist. So until then, here’s a helpful command that will help you to figure out how it works.

1$~ tuist --help

Bye 😆