? ? 在使用socket過程中出現(xiàn)了一些問題。最后終于解決了bug弟疆,在這里和大家分享一下。
使用SocketRocket 盗冷,下載下來庫文件進(jìn)行使用的時(shí)候怠苔,直接導(dǎo)入的庫,出現(xiàn)了一下問題仪糖。
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)
出現(xiàn)這些情況是因?yàn)橐眠@塊出了問題锅劝,
最后需要導(dǎo)入庫文件攒驰,
在項(xiàng)目targets中選擇build phases選項(xiàng)中l(wèi)ink binary with libaries 中添加 libicucore.tbd可解決這個(gè)錯(cuò)誤。
如使用的是cocopods導(dǎo)入的SocketRocket故爵。
則會(huì)出現(xiàn)三個(gè)警告玻粪。
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);
替換掉就可以了