使用CFSocketStream编译时错误

时间:2013-03-13 07:36:50

标签: ios sockets networking bonjour cfnetwork

以下代码行导致iOS应用程序中出现编译错误

CFStreamCreatePairWithSocketToNetService(kCFAllocatorDefault, (__bridge CFNetServiceRef)netService, &readStream, &writeStream);

如果我用 CFStreamCreatePairWithSocketToHost 替换代码,它运行正常。

错误如下;

Undefined symbols for architecture i386:
"_CFStreamCreatePairWithSocketToNetService", referenced from:
  -[Connection connect] in Connection.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

实际上,解决方案是将CFNetwork框架添加到构建阶段。我以某种方式错过了它。