可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am currently using Instruments via a bash script to initiate the command-line interface to start up runs of the Automation plug-in.
With 4.2, this worked well enough, however with the upgrade to Xcode 4.3, I am now being prompted for an authorized user to 'analyze other processes'. No user is ever actually authenticated, even if the correct credentials are granted. I get the following error:
Failed to authorize rights (0x20) with status: -60007. 2012-02-27 19:30:37.232 instruments[54151:1c03] Failed to connect to local pid watcher service: (os/kern) failure
Even with the authentication failure, the Automation plug-in executes, however this requires my script to have a physical babysitter enter credentials, which in many ways defeats the purpose of these command-line runs. Is it possible to add the user details as arguments? Or is there some other way to skip over this prompt without requiring a person at the keys?
-- EDIT --
This authorization dialog appears when you try to run UIAutomation tests from the GUI for the first time.

Filed a radar rdar://10945962.
-- EDIT --
Once the authorization dialog has been answered in the GUI, the prompts stop appearing on the command-line. This kind of work-around doesn't seem valid as an 'answer' though.
回答1:
Here's a wonderful command that may work for you:
security unlock-keychain -p [password] "${HOME}/Library/Keychains/login.keychain"
It's the command-line way to gain access to a keychain on the Mac. I haven't tested it with Automation, but it's how I've integrated my iOS builds with Jenkins.
(Replace [password] with the password)
回答2:
Okay I think I got it working.
Here are some more details about how to remove xcode command line authorization prompt
What I did was the following:
Now I am being able to use jenkins to run my UIAutomation-Tests via Command Line Script
回答3:
Adding to Alexander's answer, I found that for Mavericks, because of the way authorizations are handled (source), you should do this:
sudo security authorizationdb write system.privilege.taskport allow
I am running zucchini functional tests through a Jenkins job in a VMWare VM, and the slave couldn't launch properly the simulator and would hang on the splash screen, probably because of incorrect authorisations. This helped me solve this issue, hope it helps others.
回答4:
The user your script runs as has to be authorized to use the developer tools. You can do this two ways:
Keep in mind that for the UIAutomation instruments to work properly, the user you are invoking Instruments from will also need to be a user that can start a window server (i.e. run the UI) - and will have to be logged in to a window server when UIAutomation runs.
These two things are two of the four or five secrets to using UIAutomation with Jenkins.
回答5:
I partially solved this issue. I run instruments from command line and have authorization prompt in GUI (once per session) + this in console (each time I run instruments):
Instruments: Instruments wants permission to analyze other processes. Type your password to allow this. Name ([my-username]): Password: Failed to authorize rights (0x20) with status: -60007. 2012-02-28 10:04:19.607 instruments[60398:1203] Failed to connect to local pid watcher service: (os/kern) failure
I compared /etc/authorization file before and after upgrading to xCode 4.3. Apple replaced two keys:
com.apple.dt.instruments.process.analysis com.apple.dt.instruments.process.kill
with
com.apple.instruments.process.analysis
I edited /etc/authorization, added missing keys below new one and issue from console is solved. Unfortunately GUI prompt is still there.
Mising keys:
com.apple.dt.instruments.process.analysis allow-root class user comment Rights for Instruments group admin shared timeout 36000 com.apple.dt.instruments.process.kill allow-root class user comment Rights for Instruments group admin shared timeout