问题
I'm trying to use the @keychain option with the -p switch in altool in order to load my iTunes Connect password from the keychain:
altool --validate-app -f "${IPA}" -u "redacted" -p "@keychain:?????"
I'm trying to figure out what I need to enter after @keychain:. Everything I try (path of the keychain file, name of the keychain entry, username in the keychain entry) produces the following error:
*** Error: The specified item could not be found in the keychain.
altool supplies the following info about the -p param:
-p, --password Password. Required if username specified. Password is read from stdin if one is not supplied.
May use @keychain: or @env: prefixes followed by the keychain or environment variable lookup name.
e.g. -p @env:SECRET which would use the value in the SECRET environment variable.
回答1:
The way that worked for me was logging in with the Application Loader itself (check the "Keep me logged in" option) and use the keychain entry of the Application Loader.
So my command looks like this:
altool --validate-app -f APPLICATION.ipa -u my@apple.id -p @keychain:"Application Loader: my@apple.id"
回答2:
The correct usage is to enter the name of the keychain item (not the name of the keychain itself, and not the "Account" field for the keychain item).
My problem was actually related to access control. I had to edit the keychain item in Keychain Access and tweak the Access Control settings to allow altool to see the keychain item.
回答3:
Prerequisites:
- You need an Apple developer account, obviously. That's
AC_USERNAME. - You need a password for that account. If you can have two-factor authentication enabled, you need to create an app-specific password (beyond the scope of this answer). The password is
AC_PASSWORD. - The keychain item is going to need a name that is references via
altool's@keychainparameter. We call thisITEM_NAME.
In the instructions below, replace AC_USERNAME, AC_PASSWORD and ITEM_NAME with the values you need. Do not type these names verbatim.
Now:
- Create a generic password in your keychain.
- You can do so via
Keychain Access.appFile > New Password Item … . In the Keychain Item Name, enter the name you want forITEM_NAME, the Account Name is yourAC_USERNAMEand theAC_PASSWORDgoes into the Password field. - Or you can do it via the command line:
security add-generic-password -a "AC_USERNAME" -w "AC_PASSWORD" -s "ITEM_NAME"
- You can do so via
- In the arguments to
altool, you now pass-u AC_USERNAME -p "@keychain:ITEM_NAME"to make it fetch the password from the keychain. - The first time you run
altool, you get a security confirmation dialog asking you whether to allowaltoolto read the password. Enter your keychain password and click onAlways allow.
To prevent the security confirmation dialog from appearing, either click on Always allow or modify the appropriate keychain entry. This works like this:
- Locate the path to
altoolby opening a shell and typingxcrun -find altool. - Either use this path as argument
-T <path>when creating the password using thesecurity add-generic-passwordcommand or:- Open
Keychain Access.app. - Select the password entry, select the menu
File > Get Info(or press Cmd+I or click theⓘicon). - In this dialog, select the
Access Controltab and press the+button. A file selection dialog opens. - Open Finder and select the menu
Go > Go to Folder…and paste the path toaltool(the directory part, withoutaltoolitself, e.g./Applications/Xcode.app/Contents/Developer/usr/bin/). - Drag
altoolto the open panel ofKeychain Accessand press theAddbutton.
- Open
来源:https://stackoverflow.com/questions/32976976/how-should-the-keychain-option-be-used-for-altool