Usage

Dependencies

Examples

Building at scale

Commands

Contributors

Dynamic configurations

There are certain scenarios where you might need to customize the projects at generation time. For example, if you are building a white-label app, you might want to use the same project structure, but adjust some attributes in a per-app basis. For example, the name of the app.

To facilitate that, Tuist allows passing configuration through environment variables that can be accessed from the manifest files. For example:

TUIST_APP_NAME=MyApp tuist focus
Copy the content

Variables can be accesed using the Environment type. Any variables following the convention TUIST_XXX defined in the environment or passed to Tuist when running commands will be accessible using the Environment type. The following example shows how we access the TUIST_APP_NAME variable:

func appName() -> String {
if case let .string(environmentAppName) = Environment.appName {
return environmentAppName
} else {
return "MyApp"
}
}
Copy the content

Accessing variables returns an instance of type Environment.Value? which can take any of the following values:

You can also retrieve the string or boolean Environment variable using either of the helper methods defined below, these methods require a default value to be passed to ensure the user gets consistent results each time. This avoids the need to define the function appName() defined above.

Environment.appName?.getString(default: "TuistApp")
Copy the content
Environment.isCI?.getBoolean(default: false)
Copy the content

By using this website, you agree to our cookie policy.