Is there a branch to support ARC out there?
ASIHTTPRequest makes judicious use of CoreFoundation bridging and C-style callbacks for CFNetwork stuff. The latter is unsupported at the moment, whereas the former is supported using code that will go away in the next Xcode 4.2 preview. It would be unwise to make all these changes - now mind you, it's certainly not a rewrite, but it would be a good bit of work either way - when a good number of the behaviors that would be used (see "WWDC Release Behavior" under "Programming With ARC Release Notes") will disappear in the next release.
ARC is publicly documented on the LLVM site.
ARC support :) please :)
You guys realize that they should NOT put it into this project until ARC is in a stable build of Xcode, right? Some of us are using libraries like this and still need a stable environment for day-to-day builds so we haven't upgraded to the Xcode 4 beta yet.
Also... if ARC is going to make our lives easier as programmers to implement instance variables and such, why does it matter to you if they add the support in this project... you should be just pulling the files into your project and not touching them anyways... and if you ARE touching them you should be subclassing them instead (unless you want to make a contribution to the project).
If you want to use this framework and use ARC in the other parts of your project, you can turn off ARC for some files in the Xcode building settings. See this post.
It's very easy to use asi-http-request in an ARC environment without changing anything, simply follow these steps:
brilliant! good to know!
Or you can go into the application's build phases, expand the Compile Sources box, and add this linker flag to every non ARC file:
I tried adding that to the Compiler Flags, but it just seems to ignore it when trying to convert to ARC. Using XCode 4.2 build 4D199
When you convert to ARC, and when you select which targets to convert, you can expand the target and select which files should or should not be included in the conversion. If the files already have -fno-objc-arc on them and Xcode wants to do ARC conversion on them, feel free to file a bug with Apple.
I've submitted a pull request (#276) that introduces a LIB target in the iPhone project. This should help with implementing what soundevolution suggested above and avoid having to do file-by-file ARC enabling/disabling in your project.
I like the static library idea, but every way I try it I get 64 compiler errors. I get no errors as long as I don't try to instantiate anything from the library in my code. As soon as I try to call [ASIHTTPRequest requestWithURL:], I get a bunch of Undefined Symbols errors. Anyone else seeing this? Lion 10.7.2/Xcode 4.2.
No, working fine for me with Lion 10.7.2 / Xcode 4.2. Have you added the Static Library target as both a dependency to your project and to the list of linked libraries?
It also might be easier to help if you can do a pastie/gist of the error messages.
Yes, it's listed under both Target Dependencies and Link Binary With Libraries. Here are the errors I'm getting:
I found something that was confusing, but hasn't fixed the problem. I had called my library ASIHTTTPRequest, and I ended up with some naming conflicts. Renaming it to ASIHTTPRequestLib resolves the ambiguity, but it still gets 64 build errors. I've updated the aforelinked gist with the latest errors.
Ah... Yes. I did have this issue, but it's an easy fix.
Basically the static library does not bring across any of the dynamically linked libraries or frameworks with it into your project. So you in your main project you need to import: libaAsiHttp.a (whatever your target is called) as well as CFNetwork framework, libz, etc, etc as per the setup instructions: http://allseeing-i.com/ASIHTTPRequest/Setup-instructions
That did it. Thank you so much! I actually came really close to your solution on my own: I had looked at the iPhone sample project, and had linked those libraries into my library, instead of the main project.
I'm trying to do as you say. The Static Library was built without ARC support, i've added the Library to the Project. But when i tried to compile, the error was in ASIHTTPRequest.h NSAutoReleasePool is Unavailable in ARC Environment.
How to solve this issue?
Check if you still have the ASI source files added to your main project as well as the static library.
Check that the library is configured to build without ARC.
Follow the installation instructions and ensure your main application still links to all the required dynamic libraries and frameworks required by ASI.
Can anyone post the static library?
BrandonCopley here's the fork I'm using https://github.com/shyam-habarakada/asi-http-request
I had the linker error when building a static library. After a frustrating hour swearing at Xcode it turned out that I hadn't added all of the source files to my library target (under build phases/compile sources). Once I fixed this it built/linked without problem and I could move on to the next error.
Similar sort of problem when using this under iOS5 with ARC, I created a separate static library project and then referenced the lib and headers, no compiler errors when coding but when I try and build my app then I get the following error to do with something about the archive not being built for the i386 architecture... Any help would be appreciated, Google hasn't been much joy - TLTasklistController is a class from my app attempting to make use of the ASI library (which I named libASIHttp.a
ld: warning: ignoring file /Users/marcus/development/libraries/ios/ASIHttp/libASIHttp.a, file was built for archive which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"OBJC_CLASS$_ASIHTTPRequest", referenced from:
objc-class-ref in TLTasklistController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Has anyone actually tried porting the code over to ARC? It seems like a worthwhile endeavor being the library is in such high demand and especially since ARC is pretty much the future of ios development.
Please use ARC (Automatic Reference Counting).
Switch to AFNetworking. - no ARC, but...it's just a better platform now.
Yeah, switch to either NSURLConnection or AFNetworking. I've used both and they work just fine.
I'm having the same issue as @suprie. I already created another library for ASI with ARC disabled. The library is compiling fine.
The problem arises when from the main target, which has ARC enabled, I include the ASI header files. The compiler complains in ASIHTTPRequest.h about NSAutoreleasePool not being available in automatic reference counting mode.
What am I missing?
@PSBT NSAutoreleasePool isn't mentioned in ASIHTTPRequest.h afaics. Can you paste in the exact error message/line number?
@jogu. Thanks for the quick response!
It appears that the project I'm working on is using an old version of the library...
The NSAutoreleasePool is in line 184 in ASIHTTPRequest.h.
// Autorelease pool for the main loop, since it's highly likely that this operation will run in a thread
I'll try updating the library and try again. Sorry about that. Thanks!
Add ARC support