API Keys read from environment variables #1075
Conversation
let processInfo = ProcessInfo.processInfo | ||
|
||
guard let value = processInfo.environment[named] else { | ||
print("‼️ Missing Environment Variable: '\(named)'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do #if DEBUG then fatalError()
if we wanted to be super obvious when doing things locally?
Not sure who has the most recent CP, probably Ryan, feel free to regen CP to revert those changes - did it to ensure everything was coupled correctly! |
Other notes: Commented out FBSnapshot tests as they're failing on CI, I attempted to change a few things but it still didn't work 😞 |
So what’s the process for adding your keys as env vars? Sent with GitHawk |
Let me get it working first then we can work that bit out 😂 |
Haven't tested it, but according to https://docs.fastlane.tools/best-practices/keys/ we can define environment variables via GITHUB_CLIENT_ID Next build from BB should pass 🤞 I've run all the tests I wanted to so I'm happy the value is getting passed all the way through. Just need to validate the fastlane route but that's more for you @rnystrom If devs want to device the keys above, they should also work for local builds via simulator. Or you can define them via |
Just installed the build from BB, can confirm all the keys are there and working fine. So if we deploy using that were solid! |
Awesome. Would love to start deploying via BB once the build number works (wasn’t getting full commit count last time I tried). So to ship locally via FastLane I’ll need to modify my bash profile? Will anything fail so we can’t ship without the keys set? Sent with GitHawk |
@rnystrom So currently I have a check I've added the check so that you can continue locally without having to define them. If we were to put I would test it, but I don't have the profiles to try the build phase! |
As for BB, it looks fine from my UI and we don't even need to use the commit counter. You can give it an abritrary number and it'll just increment each release (which would be fine for us) or just use the "timestamp" option which will always be unique! |
Time stamp sounds great 👌 Sent with GitHawk |
I haven’t checked this out locally, but what are the setup steps required to use keys on debug builds? Should we update the Contributing guide in this PR too? Planning on checking this out today and giving feedback on setup/usage. Sent with GitHawk |
Okay so there are multiple cases here: BuddyBuild
FastLane
Local Debug Builds
Reminder: I've added the Secrets.swift file to the Feel free to write this up bette and update the contributing guide! |
@Sherlouk ok so I tried exporting my keys via
And nothing passes the unit test:
How do you get this to work locally in debug builds w/out editing checked-in project files? edit: Ok great, adding the keys to the env variables for the scheme works and doesn't change any project files b/c they are stored in |
@rnystrom So unit tests won't pass unless you've enabled the job, which as per the previous comment requires |
🎉 |
No description provided.