gpt4 book ai didi

objective-c - GCDAsyncUdpSocket 不为 iOS 编译

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:22:45 25 4
gpt4 key购买 nike

我使用这个库: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

怎么了?来自库的示例编译无误。

最佳答案

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com