The Keychain is the best place to store sensitive data such as API keys, auth tokens, and login credentials. On device the data is stored encrypted. Once unlocked, you can retrieve the values you saved, keeping the sensitive data secured by the user's passcode, Face ID, or Touch ID. Using the keychain is not very straightforward, however. It has a low-level C-adapted API and is a little cumbersome to work with. In this episode we will look at how to add, query, and remove items from the keychain, then look at a popular open-source library for making storing values in the keychain much easier to implement.
Documentation Apple Documentation - Using the Keychain to Manage User Secrets - There are lots of docs on the keychain. This is a good starting point. Libraries Keychain Access - a close API wrapper around Keychain, making its use more Swifty. If you're looking to use Keychain but don't want to abstract any of its functionality, take a look at this. Square Valet - a useful library for making keychain access incredibly easy.