OGeek|极客世界-中国程序员成长平台

标题: objective-c - GCDAsyncUdpSocket 不能为 iOS 编译 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:17
标题: objective-c - GCDAsyncUdpSocket 不能为 iOS 编译

我使用这个库:https://github.com/robbiehanson/CocoaAsyncSocket

在 iPhone 上有 TCP 示例,但没有 UDP。我认为一切都应该是一样的。这是我的代码:

#import <UIKit/UIKit.h>
@class GCDAsyncUdpSocket;

@interface ThirdViewController : UIViewController
{
    GCDAsyncUdpSocket *udpSocket;
}

.m:

#import "ThirdViewController.h"
#import "DDLog.h"
#import "DDTTYLogger.h"
#import "GCDAsyncUdpSocket.h"

static const int ddLogLevel = LOG_LEVEL_VERBOSE;

@implementation ThirdViewController

- (void)viewDidLoad
{
    [DDLog addLogger:[DDTTYLogger sharedInstance]];
    udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
}

但是编译时出现错误:

Undefined symbols for architecture i386: "_OBJC_CLASS_$_DDLog",

referenced from: objc-class-ref in ThirdViewController.o "_OBJC_CLASS_$_DDTTYLogger", referenced from: objc-class-ref in ThirdViewController.o "_OBJC_CLASS_$_GCDAsyncUdpSocket", referenced from: objc-class-ref in ThirdViewController.o ld: symbol(s) not found for architecture i386

怎么了?库中的示例编译没有错误。



Best Answer-推荐答案


您必须链接 CFNetwork.framework,或者如果您正在使用自动引用计数器,请使用 -fno-objc-arc 为 GCDAsyncUdpSocket 关闭 ARC

关于objective-c - GCDAsyncUdpSocket 不能为 iOS 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9852213/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4