I am trying to parse data from a JSON file which was created from a .sh script that is executed via CLI prior to building/running the project.
The following snippet does not work since my file was created from the .sh script and never added to my application bundle.
func fetchDatadogClientId() -> String? {
guard let url = Bundle.main.url(forResource: "client_token_key", withExtension: "json"),
let data = try? Data(contentsOf: url),
let datadogResponse = try? JSONDecoder().decode(DatadogResponse.self, from: data)
else {
return nil
}
return datadogResponse.clientToken
}
Would there be a way to read from this JSON file outside the application bundle or perhaps add the file to the project bundle using a script that would be run during the Build Phases?
Any suggestions are appreciated. Thanks in advance.