You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When first committing the Movie Manager code, I accidentally left my API key in the TMDBClient.swift file. Oops! This is a common mistake, especially when the API key is in the same file that's being edited frequently.
We shouldn't leave our API key in version control, and there are a variety of (non-perfect) ways to address this.
Store it in a separate file (Plist, JSON, etc.) that's stored on the device.
Move its constant to a Swift file that's ignored by version control.
And there are others. But since we want to keep the key private to ourselves, it's definitely not a good idea to store it in TMDBClient.swift, and we should try to find a better place to put it.
The text was updated successfully, but these errors were encountered:
We might as well store our api key to the environment variables.
Step 1: Open Xcode's scheme editor.
Step 2: Select Run/Arguments in the editor.
Step 3: Add apiKey entry for the Name, and your api key string for the Value.
Step 4: In the TMDBClient, remove your apiKey static variable, and in the Endpoints enum change apiKeyParam to this: static let apiKeyParam = "?api_key=\(ProcessInfo.processInfo.environment["apiKey", default: ""])".
When first committing the Movie Manager code, I accidentally left my API key in the TMDBClient.swift file. Oops! This is a common mistake, especially when the API key is in the same file that's being edited frequently.
We shouldn't leave our API key in version control, and there are a variety of (non-perfect) ways to address this.
And there are others. But since we want to keep the key private to ourselves, it's definitely not a good idea to store it in
TMDBClient.swift
, and we should try to find a better place to put it.The text was updated successfully, but these errors were encountered: