柯南回忆录之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);

替换掉就可以了


在此感谢万能的互联网,本文仅作学习交流使用,禁止任何形式的转载和商业用途。

请勿用于商业及非法用途,如由此引起的相关法律法规责任,与我们无关!

如有疑问,请联系。

QQ 209219018  QQ群:153123137。

你可能感兴趣的:(柯南回忆录之Socket(五))