To avoid our iOS client-side secrets being leaked by reverse engineering, we will use GYB to obfuscate them.
Install GYB
brew install nshipster/formulae/gyb
Add the following script to your target Build Phases, before Compile Sources:
find . -name '*.gyb' |
while read file; do
/usr/local/bin/gyb --line-directive '' -o "${file%.gyb}" "$file";
done
- Add Secrets.swift.gyb to your project folder
- Save your secrets with name secrets.json in the root project folder
- Build the project from XCode
- Secrets.swift should appear, add it to the project inside XCode
- Add Secrets.swift and secrets.json to your .gitignore file
- Enjoy! 🎉
Reference: Secret Management on iOS