使用Mach端口的Theos应用程序间通信 [英] Theos inter-app communication using mach ports

查看:206
本文介绍了使用Mach端口的Theos应用程序间通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在iOS 8上的应用程序和控制台应用程序之间(使用theos)发送数据.

I am trying to send data between an App and a console app (using theos) on iOS 8.

我尝试过:

应用:

CFMessagePortRef端口= CFMessagePortCreateLocal(kCFAllocatorDefault,CFSTR("co.test"),& message_callback,NULL,NULL);

这很好. NSLog(@%@",port)返回:

< CFMessagePort 0x17018bef0 [0x198094f50]> {已锁定=也许,有效=是,远程=否,名称= co.test,源= 0x0,标注= message_callback(0x1000e979c),上下文=< CFMessagePortcontext 0x0>}

但是,当尝试在控制台应用程序上执行相同操作时:

CFMessagePortRef端口= CFMessagePortCreateLocal(kCFAllocatorDefault,CFSTR("co.test"),& message_callback,NULL,NULL);

我总是会收到错误:

*** CFMessagePort:bootstrap_register():失败1100(0x44c)'权限被拒绝',端口= 0xc03,名称='co.test'

*** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0xc03, name = 'co.test'

即使我对两个都使用相同的 com.apple.security.application-groups 权利:

Even though I am using the same com.apple.security.application-groups entitlement for both:

<key>com.apple.security.application-groups</key>
<array>
    <string>co.test</string>
</array>

任何人都可以找到答案-也许以上所述是一种糟糕的方法,而我却错过了实现目标的更简单的方法?

Can anyone shed any light - maybe the above is a terrible approach and I am missing an easier way to accomplish my goal?

我的目标是能够在SpringBoard上运行的应用程序与使用theos构建的守护程序之间传递NSDictionary.

My goal is to be able to pass a NSDictionary between an app running on SpringBoard and a daemon built with theos.

注意:我无意在应用商店中分发此应用

推荐答案

应用程序:....... CFSTR("co.test")
控制台应用程序:... CFSTR("co.test")

您需要在应用程序组标识符的末尾附加一个附加字符串.

You need to append an additional string to the end of your application group identifier.

苹果:

每个端口名称必须以应用程序组标识符开头,后跟一个句点(.),然后是您选择的名称.

Mach port names must begin with the application group identifier, followed by a period (.), followed by a name of your choosing.

例如,如果您的应用程序组的名称是 Z123456789.com.example.app-group ,则可以创建一个名为 Z123456789.com.example.app-group.Port_of_Kobe的马赫端口..

For example, if your application group’s name is Z123456789.com.example.app-group, you might create a Mach port named Z123456789.com.example.app-group.Port_of_Kobe.

CFMessagePort和沙箱

如果您使用相同的消息端口名称创建多个消息端口,则似乎还会发生另一次崩溃.也许来自具有相同捆绑软件ID的应用程序,或者是在其他情况下,应该只有一个消息端口并且已经在运行一个消息端口.

Another crash seems to occur if you create multiple Message Ports use the same Message Port Name. Perhaps from an app with the same bundle ID or some other situation in which there should only be a single Message Port and one is already running.

当我从/Applications/运行一个macOS应用程序版本,并通过Xcode运行另一个版本时,我注意到了这一点.

I notice it when I run one version of my macOS app from /Applications/, and another via Xcode.

*** CFMessagePort:bootstrap_register():失败1100(0x44c)'权限被拒绝',端口= 0xcd07,名称='XXXYYYZZZZ.MyAppGroupName'

*** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0xcd07, name = 'XXXYYYZZZZ.MyAppGroupName'

这篇关于使用Mach端口的Theos应用程序间通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆