objective-c - 在使用 ARC 的项目中使用 ASIHTTPRequest

标签 objective-c facebook macos asihttprequest

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

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)

最佳答案

您似乎在 Mac OS X 项目中使用了 ASIHttprequest。因此,您需要遵循此说明。

Using ASIHTTPRequest in a Mac OS X project

To use ASIHTTPRequest in a Mac project, you'll need to link against:

  • SystemConfiguration.framework + zlib (as above)
  • CoreServices.framework CFNetwork is part of the CoreServices framework on Mac OS X. Unless you are writing a console-based application, your application is probably already setup to link with CoreServices, but if not, simply add CoreServices.framework in the same way as described above.

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

关于objective-c - 在使用 ARC 的项目中使用 ASIHTTPRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13014011/

相关文章:

ios - 如何查找 webview 中的滚动位置是否滚动到末尾或顶部?

ios - 如何在 Firebase 中获取数据?

ios - 如何在创建 Open Graph 对象时抑制 Facebook 默认创建操作(发布)

objective-c - 将应用程序从碳迁移到 cocoa

html - Windows(Chrome、Edge 等)和 Macos(Safari)中的边距不同

macos - 在 macOS 中将 Docker 镜像文件存储在外部驱动器上

objective-c - 如何以编程方式在 mac os x 中禁用/断开以太网适配器?

iphone - iOS YouTube和类似Safari的电影播放器

ios - 无法在 native facebook 共享对话框中设置 ios9 中的初始文本

android - Facebook 应用程序 - 如何不将请求链接到 native 应用程序