The following classes are available globally.
A one-stop shop to aggregate configuration properties from different sources, including command-line arguments, environment variables, files, URLs and raw objects into a single configuration store. Once the store has been populated configuration data can be accessed and retrieved for an individual value, or multiple values, resources can also be removed.
import Configuration let manager = ConfigurationManager() manager.load(file: "config.json").load(.environmentVariables)
To get configuration values after they have been loaded, use:
The configuration store is represented as a tree, where the path elements in keys are delimited by colons (
:). The value returned is typed as
Any?, therefore it’s important to cast the value to the type you want to use.
When aggregating configuration data from multiple sources, if the same configuration key exists in multiple sources the one most recently loaded will override those loaded earlier. In the example below the value for
["foo": "baz"]was more recently loaded than
["foo": "bar"]. The same behaviour applies to all other
manager.load(["foo": "bar"]).load(["foo": "baz"])
public class ConfigurationManager