29

我目前正在通过 bash 脚本使用 Instruments 来启动命令行界面以启动自动化插件的运行。

在 4.2 中,这运行得很好,但是随着升级到 Xcode 4.3,我现在被提示让授权用户“分析其他进程”。即使授予了正确的凭据,也没有真正对用户进行身份验证。我收到以下错误:

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

即使身份验证失败,Automation 插件也会执行,但这需要我的脚本让物理保姆输入凭据,这在许多方面违背了这些命令行运行的目的。是否可以将用户详细信息添加为参数?或者有没有其他方法可以跳过这个提示而不需要一个人在钥匙上?

- 编辑 -

当您第一次尝试从 GUI 运行 UIAutomation 测试时,会出现此授权对话框。

在此处输入图像描述

提交了雷达 rdar://10945962

- 编辑 -

在 GUI 中回答授权对话框后,提示将停止出现在命令行上。不过,这种解决方法似乎不是有效的“答案”。

4

11 回答 11

18

好吧,我想我成功了。

以下是有关如何删除xcode 命令行授权提示的更多详细信息

我所做的是以下内容:

  • 将 jenkins 用户标记为管理员(不幸的是,似乎没有其他方式 atm)
  • 转到/etc/authorization
  • 搜索密钥system.privilige.taskport
  • 将 allow-root 的值更改为 true

    <key>system.privilege.taskport</key>
    <dict>
        <key>allow-root</key>
        <false/> // change to -> <true>
        <key>class</key>
        <string>user</string>
        <key>comment</key>
        <string>Used by task_for_pid(...).
        ...
    </dict>
    

现在我可以使用 jenkins 通过命令行脚本运行我的 UIAutomation-Tests

于 2012-07-10T14:52:09.697 回答
14

这是一个可能对您有用的绝妙命令:

security unlock-keychain -p [password] "${HOME}/Library/Keychains/login.keychain"

这是在 Mac 上访问钥匙串的命令行方式。我还没有使用自动化对其进行测试,但这就是我将我的 iOS 构建与 Jenkins 集成的方式。

将 [password] 替换为密码

于 2012-03-13T05:01:07.280 回答
10

添加到亚历山大的回答中,我发现对于小牛队,由于授权的处理方式(来源),您应该这样做:

sudo security authorizationdb write system.privilege.taskport allow

我正在通过 VMWare VM 中的 Jenkins 作业运行西葫芦功能测试,并且从站无法正确启动模拟器并会挂在启动画面上,可能是因为授权不正确。这帮助我解决了这个问题,希望对其他人有所帮助。

于 2014-01-07T02:58:48.240 回答
5

您的脚本运行的用户必须被授权使用开发者工具。您可以通过以下两种方式执行此操作:

  • 将用户添加到_developer组: sudo dscl . append /Groups/_developer GroupMembership scriptusername

  • 使用 DevToolsSecurity 命令行工具

请记住,要使 UIAutomation 工具正常工作,您从中调用 Instruments 的用户还需要是可以启动窗口服务器(即运行 UI)的用户 - 并且必须登录到窗口服务器当 UIAutomation 运行时。

这两件事是使用 UIAutomation 和 Jenkins 的四个或五个秘密中的两个。

于 2012-05-15T05:06:06.290 回答
4

我部分解决了这个问题。我从命令行运行仪器并在 GUI 中有授权提示(每个会话一次)+ 在控制台中(每次我运行仪器):

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

我比较了升级到 xCode 4.3 前后的 /etc/authorization 文件。苹果更换了两把钥匙:

<key>com.apple.dt.instruments.process.analysis</key>
<key>com.apple.dt.instruments.process.kill</key>

<key>com.apple.instruments.process.analysis</key>

我编辑了 /etc/authorization,在新的下面添加了缺少的键,控制台的问题得到了解决。不幸的是 GUI 提示仍然存在。

缺少键:

<key>com.apple.dt.instruments.process.analysis</key>
<dict>
    <key>allow-root</key>
    <true/>
    <key>class</key>
    <string>user</string>
    <key>comment</key>
    <string>Rights for Instruments</string>
    <key>group</key>
    <string>admin</string>
    <key>shared</key>
    <true/>
    <key>timeout</key>
    <integer>36000</integer>
    </dict>
<key>com.apple.dt.instruments.process.kill</key>
<dict>
    <key>allow-root</key>
    <true/>
    <key>class</key>
    <string>user</string>
    <key>comment</key>
    <string>Rights for Instruments</string>
    <key>group</key>
    <string>admin</string>
    <key>shared</key>
    <true/>
    <key>timeout</key>
    <integer>5</integer>
</dict>

希望这会为您解决整个问题

于 2012-03-14T07:58:36.200 回答
3

我在 El Capitan 上也遇到过这个问题。我发现这篇文章很有帮助https://www.dssw.co.uk/reference/authorization-rights/。基于此,我更改了以下权限以解决此问题:

system.privilege.taskport
system.privilege.taskport.debug
system.privilege.taskport.safe
com.apple.dt.instruments.process.analysis
com.apple.dt.instruments.process.kill
于 2016-06-14T15:11:58.560 回答
1

这是对我有用的解决方案:

<key>system.privilege.taskport</key>
<dict>
<key>allow-root</key>
<false/> 
<key>class</key>
<string>user</string> // change to -> allow
<key>comment</key>
<string>Used by task_for_pid(...).
...
</dict>
于 2013-10-24T18:35:41.963 回答
1
sudo security authorize -u [username]

为我工作。

于 2013-11-12T09:14:00.403 回答
0

我还尝试了安全解锁钥匙串并更改了 /etc/authorization 文件,并启用了 DevToolsSecurity,但它们都没有工作,直到我启动 Instruments GUI 应用程序并运行我的脚本,它从中弹出一个对话框,我输入了我的密码,然后当我再次运行仪器脚本时,它不再需要密码了!

于 2013-08-09T05:33:01.797 回答
0

在 Xcode 中 - 如果您加载管理器 (Xcode->Window->Organizer)

然后在设备下选择您的机器->“启用开发者模式”

这应该消除对仪器提示的需要。

于 2014-05-24T20:34:24.153 回答
-1

我尝试了安全解锁钥匙串并编辑 /etc/authorization 文件,但这些都不起作用。

最后,唯一删除该安全提示的是 jacekmigacz 在评论中建议运行“sudo DevToolsSecurity --enable”。

于 2013-07-18T22:54:42.333 回答