柯南回忆录之Socket(五)

    在使用socket过程中出现了一些问题。最后终于解决了bug,在这里和大家分享一下。

使用SocketRocket ,下载下来库文件进行使用的时候,直接导入的库,出现了一下问题。

Apple Mach-O Linker (ld) Error Group

1、"_utf8_nextCharSafeBody", referenced from:

2、clang: error: linker command failed with exit code 1 (use -v to see invocation)

出现这些情况是因为引用这块出了问题,

最后需要导入库文件,

在项目targets中选择build phases选项中link binary with libaries 中添加 libicucore.tbd可解决这个错误。

如使用的是cocopods导入的SocketRocket。

则会出现三个警告。

Semantic Issue Group

1、/............../Pods/SocketRocket/SocketRocket/SRWebSocket.m:509:5: Ignoring return value of function declared with 'warn_unused_result' attribute

2、/............../Pods/SocketRocket/SocketRocket/SRWebSocket.m:629:13: Enumeration value 'NSURLNetworkServiceTypeCallSignaling' not handled in switch

3、/............../Pods/SocketRocket/SocketRocket/SRWebSocket.m:1485:9: Ignoring return value of function declared with 'warn_unused_result' attribute

1、SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);

解决办法:在前面加上(void)即如下所示:

(void)SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);

替换掉就可以了

2、switch(requestNetworkServiceType) {

caseNSURLNetworkServiceTypeDefault:

break;

caseNSURLNetworkServiceTypeVoIP: {

networkServiceType =NSStreamNetworkServiceTypeVoIP;

#if TARGET_OS_IPHONE && __IPHONE_9_0

if(floor(NSFoundationVersionNumber) >NSFoundationVersionNumber_iOS_8_3) {

staticdispatch_once_tpredicate;

dispatch_once(&predicate, ^{

NSLog(@"SocketRocket: %@ - this service type is deprecated in favor of using PushKit for VoIP control", networkServiceType);

});

}

#endif

break;

}

caseNSURLNetworkServiceTypeVideo:

networkServiceType =NSStreamNetworkServiceTypeVideo;

break;

caseNSURLNetworkServiceTypeBackground:

networkServiceType =NSStreamNetworkServiceTypeBackground;

break;

caseNSURLNetworkServiceTypeVoice:

networkServiceType =NSStreamNetworkServiceTypeVoice;

break;

}

解决办法:在后面加上default 即如下所示:

switch(requestNetworkServiceType) {

caseNSURLNetworkServiceTypeDefault:

break;

caseNSURLNetworkServiceTypeVoIP: {

networkServiceType =NSStreamNetworkServiceTypeVoIP;

#if TARGET_OS_IPHONE && __IPHONE_9_0

if(floor(NSFoundationVersionNumber) >NSFoundationVersionNumber_iOS_8_3) {

staticdispatch_once_tpredicate;

dispatch_once(&predicate, ^{

NSLog(@"SocketRocket: %@ - this service type is deprecated in favor of using PushKit for VoIP control", networkServiceType);

});

}

#endif

break;

}

caseNSURLNetworkServiceTypeVideo:

networkServiceType =NSStreamNetworkServiceTypeVideo;

break;

caseNSURLNetworkServiceTypeBackground:

networkServiceType =NSStreamNetworkServiceTypeBackground;

break;

caseNSURLNetworkServiceTypeVoice:

networkServiceType =NSStreamNetworkServiceTypeVoice;

break;

default:

break;

}

3、SecRandomCopyBytes(kSecRandomDefault,sizeof(uint32_t), (uint8_t*)mask_key);

解决办法:在前面加上(void)即如下所示:

(void)SecRandomCopyBytes(kSecRandomDefault,sizeof(uint32_t), (uint8_t*)mask_key);

替换掉就可以了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 前言 本文会用实例的方式,将iOS各种IM的方案都简单的实现一遍。并且提供一些选型、实现细节以及优化的建议。 注:...
    maTianHong阅读 2,401评论 4 12
  • 1、禁止手机睡眠 [UIApplication sharedApplication].idleTimerDisab...
    小小夕舞阅读 1,485评论 1 1
  • 转自:https://www.jianshu.com/p/10b2323f502e 1、禁止手机睡眠 [UIApp...
    aggie1024阅读 2,685评论 0 6
  • 一些常用代码的总结 1、禁止手机睡眠 [UIApplication sharedApplication].idle...
    小和大大阅读 1,458评论 0 4
  • 表情是什么,我认为表情就是表现出来的情绪。表情可以传达很多信息。高兴了当然就笑了,难过就哭了。两者是相互影响密不可...
    Persistenc_6aea阅读 125,872评论 2 7