使用ASIHTTPRequest和使用ARC的项目

hoc*_*man 3 macos facebook objective-c 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
Run Code Online (Sandbox Code Playgroud)

然后在项目的构建阶段添加-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)
Run Code Online (Sandbox Code Playgroud)

我想用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];
Run Code Online (Sandbox Code Playgroud)

如果我添加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)
Run Code Online (Sandbox Code Playgroud)

小智 6

您似乎正在使用ASIHttprequestMac OS X项目.所以你需要遵循这个指令.

在Mac OS X项目中使用ASIHTTPRequest

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

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

来自:http://allseeing-i.com/ASIHTTPRequest/Setup-instructions