Mac App 中的 CoreBluetooth 权利

Posted

技术标签:

【中文标题】Mac App 中的 CoreBluetooth 权利【英文标题】:CoreBluetooth entitlements in Mac App 【发布时间】:2014-10-29 00:32:16 【问题描述】:

我正在尝试在这里构建我的第一个 mac 应用程序。这是一个简单的应用程序,没有任何 UI,但严重依赖 CoreBluetooth。这可能是我第一次为 OS X 开发,但我的日常工作是为 ios 开发,所以我对开发问题并不陌生。

到目前为止,我的应用还没有被沙盒化,因为我想测试它没有任何问题。现在我正在尝试发布它,显然我必须启用沙盒。由于我依赖 CoreBluetooth,我显然启用了蓝牙权利,但是当我将应用程序存档并保存到 Mac App Store 时,蓝牙功能不起作用(如果我直接从 Xcode 运行,它确实有效。)。

控制台显示以下日志:

29/10/2014 00:23:10.782 appleeventsd[25]: Sandboxed application with pid 7652 attempted to lookup App:"System Events"/"com.apple.systemevents" 7655/0x0:0x92092 sevs1000 sess=100005 bundleID= but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke272()/appleEventsD.cp #2463) com.apple.root.default-qos
29/10/2014 00:23:10.819 sandboxd[118]: ([7652]) My App(7652) deny appleevent-send com.apple.systemevents
29/10/2014 00:23:10.856 appleeventsd[25]: Sandboxed application with pid 7652 attempted to lookup App:"System Events"/"com.apple.systemevents" 7655/0x0:0x92092 sevs1010 sess=100005 bundleID= but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke272()/appleEventsD.cp #2463) com.apple.root.default-qos
29/10/2014 00:23:10.889 sandboxd[118]: ([7652]) My App(7652) deny appleevent-send com.apple.systemevents
29/10/2014 00:23:11.004 appleeventsd[25]: Sandboxed application with pid 7652 attempted to lookup App:"System Events"/"com.apple.systemevents" 7655/0x0:0x92092 sevs1010 sess=100005 bundleID= but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke272()/appleEventsD.cp #2463) com.apple.root.default-qos
29/10/2014 00:23:11.021 sandboxd[118]: ([7652]) My App(7652) deny appleevent-send com.apple.systemevents
29/10/2014 00:23:11.281 appleeventsd[25]: Sandboxed application with pid 7652 attempted to lookup App:"System Events"/"com.apple.systemevents" 7655/0x0:0x92092 sevs1010 sess=100005 bundleID= but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke272()/appleEventsD.cp #2463) com.apple.root.default-qos
29/10/2014 00:23:11.304 sandboxd[118]: ([7652]) My App(7652) deny appleevent-send com.apple.systemevents
29/10/2014 00:23:11.738 appleeventsd[25]: Sandboxed application with pid 7652 attempted to lookup App:"System Events"/"com.apple.systemevents" 7655/0x0:0x92092 sevs1010 sess=100005 bundleID= but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke272()/appleEventsD.cp #2463) com.apple.root.default-qos
29/10/2014 00:23:11.760 sandboxd[118]: ([7652]) My App(7652) deny appleevent-send com.apple.systemevents
29/10/2014 00:23:12.659 appleeventsd[25]: Sandboxed application with pid 7652 attempted to lookup App:"System Events"/"com.apple.systemevents" 7655/0x0:0x92092 sevs1010 sess=100005 bundleID= but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke272()/appleEventsD.cp #2463) com.apple.root.default-qos
29/10/2014 00:23:12.681 sandboxd[118]: ([7652]) My App(7652) deny appleevent-send com.apple.systemevents
29/10/2014 00:23:14.565 appleeventsd[25]: Sandboxed application with pid 7652 attempted to lookup App:"System Events"/"com.apple.systemevents" 7655/0x0:0x92092 sevs1010 sess=100005 bundleID= but was denied due to sandboxing. (___ZL13handleMessageP17_xpc_connection_sPv_block_invoke272()/appleEventsD.cp #2463) com.apple.root.default-qos
29/10/2014 00:23:14.601 sandboxd[118]: ([7652]) My App(7652) deny appleevent-send com.apple.systemevents
29/10/2014 00:23:14.630 sandboxd[118]: ([7652]) My App(7652) deny mach-lookup com.apple.blued

所以我尝试在以下键下输入权利:com.apple.security.temporary-exception.apple-events 用于 com.apple.bluedcom.apple.systemevents,但这也没有帮助。 Xcode 6.1 中的蓝牙权利是否被破坏?还是我在这里监督一些大事?

【问题讨论】:

【参考方案1】:

这似乎已通过将我的代码签名权利更改为正确来解决:我习惯于对 iOS 应用程序进行代码签名,而 OS X 似乎是另一个问题。我不得不将我的代码签名更改为自动和开发人员。然后点击“Mac App Store”切换按钮就可以了:)

【讨论】:

以上是关于Mac App 中的 CoreBluetooth 权利的主要内容,如果未能解决你的问题,请参考以下文章

CoreBluetooth - 未为服务设置 UUID

在 mac osx 10.13 CoreBluetooth 框架上的 CBPeripheralStateDisconnecting 状态之后,外设状态永远不会改变

CoreBluetooth 框架可以用来连接非 Apple 设备吗?

在后台使用 iBeacon 或 CoreBluetooth 识别 iOS 设备

iOS CoreBluetooth 教程 蓝牙

在 OSX 上模拟 HID:IOBluetooth 还是 CoreBluetooth?