Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何解决xpc.h未找到错误?_Ios_Sms_Xpc - Fatal编程技术网

Ios 如何解决xpc.h未找到错误?

Ios 如何解决xpc.h未找到错误?,ios,sms,xpc,Ios,Sms,Xpc,我正在开发一个iOS应用程序,在这个应用程序中,我在没有用户参与的情况下在内部发送SMS。在谷歌搜索之后,我找到了答案,我正在使用这个代码 xpc_connection_t myconnection; dispatch_queue_t queue = dispatch_queue_create("com.apple.chatkit.clientcomposeserver.xpc", DISPATCH_QUEUE_CONCURRENT); myconnection = xpc_connecti

我正在开发一个iOS应用程序,在这个应用程序中,我在没有用户参与的情况下在内部发送SMS。在谷歌搜索之后,我找到了答案,我正在使用这个代码

xpc_connection_t myconnection;

dispatch_queue_t queue = dispatch_queue_create("com.apple.chatkit.clientcomposeserver.xpc", DISPATCH_QUEUE_CONCURRENT);

myconnection = xpc_connection_create_mach_service("com.apple.chatkit.clientcomposeserver.xpc", queue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);
现在我们有了XPC连接,我连接到短信发送服务。然而,XPC配置提供了创建挂起连接的功能——我们还需要采取一个步骤来激活

xpc_connection_set_event_handler(myconnection, ^(xpc_object_t event){
xpc_type_t xtype = xpc_get_type(event);
if(XPC_TYPE_ERROR == xtype)
{
NSLog(@"XPC sandbox connection error: %s\n", xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION));
}
// Always set an event handler. More on this later.

NSLog(@"Received an message event!");

});

xpc_connection_resume(myconnection);
连接已激活。此时,iOS 6将在电话日志中显示一条消息,禁止这种通信。现在我们需要生成一个类似于xpc_字典的字典,其中包含消息发送所需的数据

NSArray *receipements = [NSArray arrayWithObjects:@"+7 (90*) 000-00-00", nil];

NSData *ser_rec = [NSPropertyListSerialization dataWithPropertyList:receipements format:200 options:0 error:NULL];

xpc_object_t mydict = xpc_dictionary_create(0, 0, 0);
xpc_dictionary_set_int64(mydict, "message-type", 0);
xpc_dictionary_set_data(mydict, "recipients", [ser_rec bytes], [ser_rec length]);
xpc_dictionary_set_string(mydict, "text", "hello from your application!");
剩下的很少了:将消息发送到XPC端口并确保消息已送达

xpc_connection_send_message(myconnection, mydict);
xpc_connection_send_barrier(myconnection, ^{
NSLog(@"Message has been successfully delievered");
});
但是为了使用这段代码,我必须添加xpc.h头文件,但是找不到xpc.h头文件。所以,建议我实际需要做什么


库路径错误使用此


#include/usr/include/xpc/xpc.h

您在iOS中使用的是xpc,默认情况下,头不会出现在那里。我从中得到了/usr/include,它包括xpc.h和相关的头文件。我从中获取/xpc子目录,只将其添加到我的项目中,因为添加完整的/usr/include会干扰现有的/usr/include,并在编译时导致架构错误

即使在添加/xpc子目录并包含xpc.h之后,由于嵌套的include问题,我也无法使include路径正常工作。为了得到正确的解决方案,浪费了很多时间,然后使用了编辑xpc.h和base.h的笨拙解决方案,这样嵌套的xpc include就不会使用任何路径。因此,
#include
被编辑为
#include“base.h”
,等等


这就成功了,应用程序在此之后生成并运行。

签入你的应用程序包,错误表明你的包几乎无法从你的应用程序包中删除。这是一个很好的解决方案。我刚刚下载了代码并添加到project中以解决问题。不需要创建符号链接