Skip to content
This repository

ARC Support? #210

Open
ghost opened this Issue June 15, 2011 · 32 comments
Deleted user
ghost commented June 15, 2011

The content you are editing has changed. Reload the page and try again.

Is there a branch to support ARC out there?

Sending Request…

Attach images by dragging & dropping or selecting them. Octocat-spinner-32 Uploading your images… Unfortunately, we don't support that file type. Try again with a PNG, GIF, or JPG. Yowza, that's a big file. Try again with an image file smaller than 10MB. This browser doesn't support image attachments. We recommend updating to the latest Internet Explorer, Google Chrome, or Firefox. Something went really wrong, and we can't process that image. Try again.

Zachary Waldowski

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.

Michael Mayo
Collaborator
Clément Hussenot

ARC support :) please :)

Mark Rickert

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).

Kai

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.

Matt Connolly

It's very easy to use asi-http-request in an ARC environment without changing anything, simply follow these steps:

  1. Simply create a static library target.
  2. Add asi-http-request files as required to the library target
  3. Configure the target to build without ARC
  4. Add that static library as a dependency to your app target
  5. Add that static library in the build phases link section.

Et violá!

Michael Mayo
Collaborator

brilliant! good to know!

Mark Rickert

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:

-fno-objc-arc

Adam Hartley

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

Matt Connolly

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.

shyam-habarakada

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.

Zev Eisenberg

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.

Matt Connolly

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.

Zev Eisenberg

Yes, it's listed under both Target Dependencies and Link Binary With Libraries. Here are the errors I'm getting:

https://gist.github.com/1311248

Zev Eisenberg

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.

Matt Connolly

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

Zev Eisenberg

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.

suprie

Hi,
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?

Matt Connolly

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.

Brandon Copley

Can anyone post the static library?

John Cinnamond

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.

Marcus Bond

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)

Brian Douglas Moakley

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.

TJ Rana

Please use ARC (Automatic Reference Counting).

Brandon Copley

Switch to AFNetworking. - no ARC, but...it's just a better platform now.

Michael Mayo
Collaborator

Yeah, switch to either NSURLConnection or AFNetworking. I've used both and they work just fine.

Pedro Bolaños

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?

Thanks!

Joseph Heenan
Collaborator

@PSBT NSAutoreleasePool isn't mentioned in ASIHTTPRequest.h afaics. Can you paste in the exact error message/line number?

Pedro Bolaños

@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
NSAutoreleasePool *pool;

I'll try updating the library and try again. Sorry about that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.