Timeline for Xcode: how to compile environment variables and refer to them in Swift?
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 29, 2021 at 9:39 | comment | added | Shruti | @sschilli did you figured out how to pass data from Jenkins to Xcode? I also want to achieve the same. can you please help me out | |
| Nov 7, 2019 at 16:48 | vote | accept | sschilli | ||
| Nov 6, 2019 at 0:07 | comment | added | Alexander | Your script could inject the api key into a place holder of a Swift class, like Sombre's answer shows. You could also just write it to an plist/xml/json/yaml/whatever file that will be bundled into your app, and read it from there at runtime. | |
| Nov 5, 2019 at 20:16 | history | edited | sschilli | CC BY-SA 4.0 |
added clarification
|
| Nov 5, 2019 at 20:14 | comment | added | sschilli | @Alexander Just to be clear, when I say "binary's environment" I mean I don't want to define an environment variable from the binary's running directory (as I have no control over the environment variables present when the app is distributed, and do not want the API key stored in our git repository). For example, if I could somehow inject an environment variable into a Swift config class of some sort that gets compiled as part of the binary, that would be an ideal solution. | |
| Nov 5, 2019 at 19:39 | answer | added | Sombre Osmo'z | timeline score: 4 | |
| Nov 5, 2019 at 19:38 | comment | added | Alexander | IDK about your CI platform, but at the worst, you can make a script that reads the CI env var, and stores it into a place that's accessible to your app. But "not have to worry about the variable being defined in the binary's environment at runtime" isn't possible. | |
| Nov 5, 2019 at 19:29 | comment | added | sschilli | @Alexander you might be misunderstanding my request. I know my app has to have the API key somehow; I am not trying to avoid that. I just want to grab it from an environment variable when the app is built and have it compiled with the app if that is possible. | |
| Nov 5, 2019 at 18:49 | comment | added | Alexander | Not really. One way or another, your app has to have it (in order to be able to transmit it to the API) | |
| Nov 5, 2019 at 18:44 | history | asked | sschilli | CC BY-SA 4.0 |