Environment
public class Environment
Gets and sets environment variables for the current process.
-
Returns a dictionary of all environment variables for the current process.
Declaration
Swift
public static var variables: [String : String] { get }
-
Class method that sets the value of the specificed environment variable.
Example:
Environment.set("NAME", to: "VALUE") Environment.set("NAME", to: "VALUE", overwrite: false)
Declaration
Swift
public static func set(_ name: String, to value: String?, overwrite: Bool = true)
Parameters
variable
Name of variable to set.
value
Value to set variable to, or nil to unset variable.
overwrite
Indicate whether value should be overwritten or not.
-
Class method that unsets the specified environment variable.
Example:
Environment.unset("NAME")
Declaration
Swift
public static func unset(_ name: String)
Parameters
variable
Name of the environment variable to unset.
-
Gets or sets an environment variable using subscript syntax.
Example:
let name = Environment["NAME"] Environment["NAME"] = "VALUE" Environment["NAME"] = nil
Declaration
Swift
public static subscript(key: String) -> String? { get set }
Parameters
key
Variable to get or set.