Learn Courses My Dashboard

How to Store Private Key Securely for a Public GitHub Repo iOS Swift Foundations Module 6

Hi CWC crew,

I’m just about to complete the entire iOS Swift Foundations course. Woot!

In the City Sights module, we use an API key that we received from Yelp! Chris mentioned that we should never store this key in a public repo.

However, I would like this app to be stored in my repo as a portfolio piece.

Can anyone point me onto a resource or offer some advice on how to separate these two? Ii understand that I can ‘store this key locally’ but how would I then import the key at runtime from a file that’s on my HDD?



Hi Shane,

You could make the repo private and then in the case of you applying for a job where you want to make that repo available to the person who is assessing your code it would be a simple case of allowing them read access to your private repo by making them a collaborator for the duration of that assessment and then remove their access at a later date. You would need to make the point that the repo is private in the interests of protecting your API key.

The other option is to leave the repo public but use gitignore to prevent the file containing the API from being committed to the repo. As in the scenario above you could provide that file to the person who is assessing your code should they want to run the Application.