【问题标题】:Using ASIHTTPRequest with project which is using ARC将 ASIHTTPRequest 与使用 ARC 的项目一起使用
【发布时间】:2012-10-22 14:51:14
【问题描述】:

我已将这些文件添加到我的项目中:

ASICacheDelegate.h
ASIDataCompressor.h
ASIDataCompressor.m
ASIDataDecompressor.h
ASIDataDecompressor.m
ASIDownloadCache.h
ASIDownloadCache.m
ASIFormDataRequest.h
ASIFormDataRequest.m
ASIHTTPRequest.h
ASIHTTPRequest.m
ASIHTTPRequestConfig.h
ASIHTTPRequestDelegate.h
ASIInputStream.h
ASIInputStream.m
ASINetworkQueue.h
ASINetworkQueue.m
ASIProgressDelegate.h

然后在项目的构建阶段添加了-fno-objc-arc,因为我的项目正在使用 ARC 并且 ASIHTTPRequest 是在没有使用它的情况下编写的。当我尝试编译我的项目时,我得到了这些错误:

Undefined symbols for architecture x86_64:
  "_SCDynamicStoreCopyProxies", referenced from:
      -[ASIHTTPRequest configureProxies] in ASIHTTPRequest.o
  "_deflate", referenced from:
      -[ASIDataCompressor compressBytes:length:error:shouldFinish:] in ASIDataCompressor.o
  "_deflateEnd", referenced from:
      -[ASIDataCompressor closeStream] in ASIDataCompressor.o
  "_deflateInit2_", referenced from:
      -[ASIDataCompressor setupStream] in ASIDataCompressor.o
  "_inflate", referenced from:
      -[ASIDataDecompressor uncompressBytes:length:error:] in ASIDataDecompressor.o
  "_inflateEnd", referenced from:
      -[ASIDataDecompressor closeStream] in ASIDataDecompressor.o
  "_inflateInit2_", referenced from:
      -[ASIDataDecompressor setupStream] in ASIDataDecompressor.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我想用 ASIHTTPRequest 做什么:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/me/photos?access_token=%@", access_token]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addFile:@"/Users/development/Desktop/12t.png" forKey:@"file"];
[request setPostValue:[NSString stringWithFormat:@"This is a test."] forKey:@"message"];
[request startAsynchronous];

如果我添加 CoreGraphics、zlib、CFNetwork 和 SystemConfiguration 框架(在我的 Xcode 中找不到 MobileCoreServices),我会收到以下错误:

Undefined symbols for architecture x86_64:
  "_Gestalt", referenced from:
      -[oglView(checkOSXVersion) checkForOSVersion:] in oglView+checkOSXVersion.o
      +[ASIHTTPRequest defaultUserAgentString] in ASIHTTPRequest.o
  "_UTTypeCopyPreferredTagWithClass", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_UTTypeCreatePreferredIdentifierForTag", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_kUTTagClassFilenameExtension", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
  "_kUTTagClassMIMEType", referenced from:
      +[ASIHTTPRequest mimeTypeForFileAtPath:] in ASIHTTPRequest.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

【问题讨论】:

    标签: objective-c facebook macos asihttprequest


    【解决方案1】:

    您似乎在 Mac OS X 项目中使用ASIHttprequest。所以你需要遵循这个指令。

    在 Mac OS X 项目中使用 ASIHTTPRequest

    要在 Mac 项目中使用 ASIHTTPRequest,您需要链接:

    • SystemConfiguration.framework + zlib(同上)
    • CoreServices.framework CFNetwork 是 Mac OS X 上 CoreServices 框架的一部分。除非您正在编写基于控制台的 应用程序,您的应用程序可能已经设置为链接 CoreServices,但如果没有,只需将 CoreServices.framework 添加到 方法与上述相同。

    发件人:http://allseeing-i.com/ASIHTTPRequest/Setup-instructions

    【讨论】:

      【解决方案2】:

      您需要添加一些必需的库,并且 ASSIHTTP 正在使用这些框架。这些框架是: -libz.dylib -系统配置 -MobileCoreServices -CFNetwork

      【讨论】:

        【解决方案3】:

        您似乎没有包含 ASI 所依赖的库。查看setup instructions,特别是第2步:

        Link with CFNetwork, SystemConfiguration, MobileCoreServices, CoreGraphics and zlib
        

        【讨论】:

        • 需要添加 libz.dylib 和 MobileCoreServices。他们绝对应该都在那里。如果不是 libz,请尝试 libz.1.2.5。
        【解决方案4】:

        试试这个: - 选择项目 - 目标 - 选择构建阶段 - 检查 ASIHTTPRequest .m 文件是否已添加到“Link Binary with Libraries”中

        【讨论】:

          【解决方案5】:

          您是否包含了所有依赖项?因为你什么都没提。 http://allseeing-i.com/ASIHTTPRequest/Setup-instructions 您还应该包括 CFNetwork、SystemConfiguration、MobileCoreServices、CoreGraphics 和 zlib。

          zlib 和 MobileCoreServices

          顺便说一句,如果你找不到 zlib(我自己没有 zlib),你可以包含 libz.x.dylib。你应该有 MobileCoreServices.framework 因为它们应该在 CoreService 框架中。如果您没有它,那么您别无选择重新安装它以使 ASI 正常工作

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多