Guide · fastlane
Use an App Store Connect key with fastlane
fastlane wants the path of a .p8 file. That file ends up in the repo folder, a Downloads folder or a backup, and it can sign in as your team.
In shortSave the .p8 as a key item, then run lk run --file ASC_KEY_PATH=shop/production/ASC_P8 -- fastlane beta. The command gets the path of a temporary file only you can read, and Latchkey deletes it when the command exits.
Why the .p8 file lingers
The App Store Connect key is a .p8 file, and fastlane reads it from a path. So the file gets saved somewhere and stays there: in the project, in a shared folder, in a backup, sometimes in Git. Anyone who can read it can use the key. Replacing it means finding every copy.
The tool needs a file, not a value in the environment. Latchkey stores the key as an item in iCloud Keychain and writes a file only for the length of the command. Your project folder never holds it, and neither does a backup of that folder.
Set it up
-
Save the key as a key item
Use the
keykind, the one meant for SSH, GPG,.p8and.pemfiles. The value is read from standard input. The file name below is an example.Terminal lk set shop/production/ASC_P8 --kind key < ~/Downloads/AuthKey_EXAMPLE.p8Saving asks for approval. Once the item is stored, delete the downloaded file. Key items are masked in command output, line by line, and only exact copies are hidden.
-
Run fastlane with
--fileNAME=IDsets the variable NAME to the path of a temporary file holding the item's value. Use the name your lane reads for the key's path.Terminal lk run --file ASC_KEY_PATH=shop/production/ASC_P8 -- fastlane betaThe file is readable only by you. Latchkey deletes it when the command exits. Temporary files for different item IDs get different paths, even if the final names match.
-
Keep the setting in the project
If you run the lane the same way every time, put it in an env file.
NAME=latchkey-file://IDdoes the same as--file, and the file contains no value..env.local ASC_KEY_PATH=latchkey-file://shop/production/ASC_P8Terminal lk run --env-file .env.local -- fastlane beta -
Check before a slow run
lk checkaccepts the same options. It shows whether the item would be released without asking, would ask you, or is missing, and it releases nothing.Terminal lk check --file ASC_KEY_PATH=shop/production/ASC_P8
With an agent
The key item asks for approval each time unless it is agent-safe or a grant covers it. Keep a production signing key out of agent-safe and grant it narrowly if you let an agent run releases. The MCP tool latchkey_run can deliver key files too. See Give coding agents API keys safely.
What this doesn't do
- While the command runs, the file exists on disk. Malware running as you could read it in that time, and so can the command and anything it starts.
- Latchkey can't control what a command does with the file. It could copy it. Masking hides exact copies of each line of the key in output, not altered ones.
- Your lane still needs the other values it reads, such as the key ID and issuer ID. Those are separate items or plain settings.
- The original
.p8you downloaded is a plain copy until you delete it.
The key files section and the security page have more.