I want to pass environment variables from the shell script that I have that calls tuist generate
. For instance either making a call like env tuist generate
or env MY_VAR="some_value" tuist generate
. |
I want to make possible to define the values like SWIFT_VERSION=“6.0” and IOS_MINIMUM_TARGET=“14.0” either in a .sh file or a .env to the Project.swift file to then generate the project.
1 Like
Hi @claudiomadureira ,
First of all, welcome to the community forum. Tuist Projects supports what the docs refer to as dynamic configuration, which solves your need.
Any variable passed with the prefix TUIST_
can then be read from the manifest files. In your particular case, you could do:
TUIST_SWIFT_VERSION=6.0 tuist generate
And then from the manifest:
func swiftVersion() -> String {
if case let .string(environmentSwiftVersion) = Environment.swiftVersion {
return environmentSwiftVersion
} else {
return "6.0" // Default value
}
}
Let me know if that helps.