1

我正在使用 SocketRocket 作为 WebSocket 库,我通过 MAC 中的 cocoabot 包管理器安装了该库,用于 iOS 6 平台。

在 appDeligate.m 中时,我将头文件

#import <SocketRocket/SRWebSocket.h>

在我正在使用的函数中:

SRWebSocket *_webSocket
_webSocket.delegate = nil;
[_webSocket close];

_webSocket = [[SRWebSocket alloc] initWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"ws://192.168.178.178:6001"]]];
_webSocket.delegate = self;

NSLog(@"Opening Connection...");
[_webSocket open];

在一个独立的项目中,这工作得很好,但是当我将它包含在我的项目中时,我收到以下错误:

ld /Users/devuser/Library/Developer/Xcode/DerivedData/myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Products/Debug-iphoneos/myProject.app/myProject normal armv7 cd /Users/devuser/Documents/cordovadev/myProject export IPHONEOS_DEPLOYMENT_TARGET=6.0 export PATH ="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/ bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer /Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2。sdk -L/Users/devuser/Library/Developer/Xcode/DerivedData/myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Products/Debug-iphoneos -F/Users/devuser/Library/Developer/Xcode/DerivedData/myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Products/ Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Users/devuser/Library/Developer/GStreamer/iPhone.sdk -filelist /Users/devuser/Library/Developer/Xcode/DerivedData/ myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Intermediates/myProject.build/Debug-iphoneos/myProject.build/Objects-normal/armv7/myProject.LinkFileList -miphoneos-version-min=6。0 -dead_strip -lresolv -lstdc++ -framework CoreAudio -framework AudioToolbox -framework VideoToolbox -framework OpenGLES -framework AssetsLibrary -framework QuartzCore -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak_framework CoreMotion -weak-lSystem -force_load /Users/devuser /Library/Developer/Xcode/DerivedData/myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Products/Debug-iphoneos/libCordova.a -ObjC -fobjc-link-runtime -framework GStreamer -lresolv -weak_framework CoreMedia -framework CoreVideo -framework OpenGLES /Users/devuser /库/开发人员/Xcode/DerivedData/myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Products/Debug-iphoneos/libCordova。a -liconv -framework CoreMotion -framework CoreLocation -framework ImageIO -framework OpenAL -framework AssetsLibrary -framework Foundation -weak_framework UIKit -framework CoreGraphics -framework AddressBook -framework AddressBookUI -framework AudioToolbox -weak_framework AVFoundation -framework CFNetwork -framework MediaPlayer -framework QuartzCore -framework SystemConfiguration -framework MobileCoreServices -lPods-myProject -Xlinker -dependency_info -Xlinker /Users/devuser/Library/Developer/Xcode/DerivedData/myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Intermediates/myProject.build/Debug-iphoneos/myProject.build/Objects-normal /armv7/myProject_dependency_info.dat -o /Users/devuser/Library/Developer/Xcode/DerivedData/myProject-fxqgbeafqfsypwclwioqqupwexue/Build/Products/Debug-iphoneos/myProject.app/myProject应用程序/我的项目应用程序/我的项目应用程序/我的项目应用程序/我的项目应用程序/我的项目应用程序/我的项目应用程序/我的项目应用程序/我的项目

架构 armv7 的未定义符号:
“_OBJC_CLASS_$_SRWebSocket”,引用自:AppDelegate.o 中的 objc-class-ref

ld:未找到架构 armv7 的符号

clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

我已经检查过了,但我找不到任何相关的东西。有什么帮助吗?

4

1 回答 1

2

我必须将套接字库链接到构建设置。

项目->构建设置->其他链接器标志->调试/发布我添加

-ObjC -l SocketRocket -l icucore -framework CFNetwork -framework Security

现在它开始工作了!

于 2016-02-15T13:29:33.933 回答