Skip to content

Commit 9edd101

Browse files
authored
Create 0999-tuist-react-native
1 parent d3fe204 commit 9edd101

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

proposals/0999-tuist-react-native

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: Tuist.io in React Native
3+
author:
4+
- Riccardo Cipolleschi
5+
date: 2023-06-19
6+
---
7+
8+
# RFC0999: Tuist.io in React Native
9+
10+
## Summary
11+
12+
Managing Xcodeproj files is error prone and time consuming.
13+
14+
The current proposal suggests to move away from manually managing `Xcodeproj` files in favor of a declarative description leveraging [Tuist.io](https://tuist.io) as tool.
15+
16+
## Basic example
17+
18+
You can have a look at it in action in this PR:
19+
20+
- https://github.com/facebook/react-native/pull/37952
21+
22+
The idea is to describe the project with a declarative approach using Swift. Tuist allows you to load the `Project.swift` file in an instance of Xcode, leveraging also code completion and type checking to ensure the correctness of the project.
23+
24+
## Motivation
25+
26+
Managing Xcodeproj files is error prone and time consuming. Those files are source of frustrations for teams using them and they have been reported as one of the main pain point when users have to migrate to a new version of React Native.
27+
28+
They are also an old way to manage projects. Even Apple realized that they are not the best approach and started developing Swift Package Manager (SwiftPM) that replace the project for developing libraries.
29+
30+
Moder approaches relies on declarative syntax to describe how the project should look like and tools that can generate a valid Xcodeproj starting from that description.
31+
32+
There are several tools that we can use, but the proposed one is [Tuist.io](https://tuist.io).
33+
34+
[Tuist.io](https://tuist.io) is OSS and currently maintained by several companies, among which Shopify, which is already a React Native partner.
35+
36+
It allows the users to describe their Apple projects in Swift (the default language for iOS), and it also leverage Xcode for type checking and code completion, ensuring that the project definition is valid at compile time.
37+
38+
## Detailed design
39+
40+
To adopt Tuist in React Native, we need to follow some steps:
41+
42+
1. Land https://github.com/facebook/react-native/pull/37952. This PR already contains a functioning project which passed all the iOS tests in CI.
43+
2. Update the CLI to install Tuist in the user machine. Tuist comes directly with a `tuistenv`additional tool, which handle the environment and version for the user.
44+
3. Update the CLI and instruct it to swap the `HelloWorld` strings in the `template/ios/Package.swift` to the AppName chosen by the user.
45+
4. Update the CLI to run `tuist generate` to create the project
46+
5. Update doctor to check that the user have tuist installed
47+
6. Remove the old Xcodeproj file and set the right `.gitignore` settings.
48+
49+
## Drawbacks
50+
51+
- Prioritization: I think that the only reason NOT to do this is for prioritization and time. Implementing this system will take some time which we can devote to other, maybe more impactful, activities.
52+
- Impact: This work could simplify updates, but recently we have started pushing all the changes to the Xcodeproj into the Cocoapods scripts. This means that the users don't have to touch the project file at all, and Cocoapods takes care of modifying the project when needed. It is still useful to have a laid-out description of the project, especially for brownfield projects that have to mimic the same configurations of a template app.
53+
- Workflow changes: there is an extra step that user has to run when modifying the project: after every change in the `Project.swift`, users have to run `tuist generate`. This is a minor issue as we do not expect for the user to manually update the `Project.swift` file at all, and we can bake most of the tuist invocations in th e CLI.
54+
55+
## Alternatives
56+
57+
### [XCodeGen](https://github.com/yonaskolb/XcodeGen)
58+
59+
This tool allows to describe the Xcodeproj using a YAML file.
60+
61+
If we go for this approach, the drawbacks are:
62+
63+
- a new language to teach our users
64+
- more verbose project description
65+
- no code completion.
66+
67+
### [Xcake](https://github.com/igor-makarov/xcake/)
68+
69+
This tool allow to describe a project in Ruby.
70+
71+
If we go for this approach, the drawbacks are:
72+
73+
- a new language to teach our users
74+
- no type checking
75+
76+
## Adoption strategy
77+
78+
- Implement all the changes before 0.73.
79+
- Communicate with a BlogPost the change, explaining the implications for new apps and updates.
80+
81+
## How we teach this
82+
83+
- Add the requirement to the website
84+
- Blogposts
85+
- Automating the workflow as much as possible.

0 commit comments

Comments
 (0)