I'm developing an Ubuntu touch app in QML, and would like to keep an API key reasonably secret (at least I don't want to have to commit it into the VCS). I see that you can define environment variables in Projects -> Build & Run -> Build Environment
, so my question is, how can I add a placeholder value in my QML that is then replaced by an environment variable at build time? Or is there a better way to do it?
The solution I came up with was to keep my secret in a special file. To my public repository, I committed only a placeholder, but I have the actual secret on my machine. In the build process, I read the secrets into build variables. These in turn are referenced in the relevant locations in my configuration files.
I don't know that this is the best solution, but it's worked pretty well for me. The downside is that the secrets file always shows up as modified in my VCS, but I've learned to ignore that.