Inject environment variables and share them between processes. Heavily inspired by swift-dotenv. A small part of the larger iOS deploy infrastructure at Plata.
Create the .context
file in your desired location with touch .context
. File search defaults to the current dir. The default file will be created automatically on load()
call.
import DotContext
let dotContext = DotContext(dotContextFileURL: <your_file_url>, delimeter: #)
// Load environment variables
try dotContext.load()
// Set new values
dotContext.set(value: .string("YOUR_VALUE"), forKey: "YOUR_KEY")
// Get values
let key = dotContext.get(key: "YOUR_KEY")
For each new process call try dotContext.load()
to load environment variables. The main difference with the SwiftDotEnv is that this one will create the .context
file automatically on dotContext.load()
and set(value:forKey:)
method will update that file with new values so it's more bidirectional.
To erase the .context file call try dotContext.erase()