I'm pretty new to Swift and Xcode so please forgive my ignorance. I am trying to set up an environment variable to store my API keys since I am planning on pushing my project to GitHub and don't want the API in a public repo. I read that using environment variables is a good way to do this. I went into Xcode and set up a scheme that included an environment variable like this:
environment variable
how do I actually reference it in Swift? I tried just putting "GMAPS_API" in the code where my API key should go, but it's not recognizing it. Am I even doing this correctly? I have tried to look online, but I am still confused. Any help or pointers in the right direction would be great. Thanks
@OOper pointed me in the right direciton. All I had to do was:
let apiKey = ProcessInfo.processInfo.environment["GMAPS_API"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With