AFNetworking compilation errors - afnetworking

I'm new to AFNetworking earlier I was using ASIHTTPRequest and now I want to shift to AFNetworking after researching a lot on google. But now when I download the Library and want to look at the example project I'm facing errors in the code.
I just compiled and I got 13 errors, please have a look at the image below, any help will be greatly appreciated.

the erros have nothing to do with AFNetworking, it's the Post.m file in your sample project. Have you declared the text and user properties in Post.h?

The example should run fine as it is provided as part of the AFNetworking script on github
These are the Requirement Notes for the AFNetworking project
https://github.com/AFNetworking/AFNetworking
AFNetworking 1.0 and higher requires either iOS 5.0 and above, or Mac
OS 10.7 (64-bit with modern Cocoa runtime) and above.
For compatibility with iOS 4.3, use the latest 0.10.x release.
ARC
AFNetworking uses ARC as of its 1.0 release.
If you are using AFNetworking 1.0 in your non-arc project, you will
need to set a -fobjc-arc compiler flag on all of the AFNetworking
source files. Conversely, if you are adding a pre-1.0 version of
AFNetworking, you will need to set a -fno-objc-arc compiler flag.
To set a compiler flag in Xcode, go to your active target and select
the "Build Phases" tab. Now select all AFNetworking source files,
press Enter, insert -fobjc-arc or -fno-objc-arc and then "Done" to
enable or disable ARC for AFNetworking.

You need to define properties of objects as unsafe_unretained/strong/weak/copy/retain/assign.

Related

Errors when adding C libraries to a project with ARC

I am trying to use a set of C libraries to allow custom graphs in my iOS project. My projects uses ARC, however, the custom graph libraries are based on a project that does not use ARC. The errors I am getting are related to ARC.
The documentation for the C libraries specify that when using the library to turn off ARC. However, my project is too evolved to revert to a non ARC project.
How might I still use this library in my project? The library is PowerPlot.
You can turn off ARC for the specific library, by adding the -fno-objc-arc compiler flag.
Go in your Target Settings > Build Phases > Compile Sources, and add the compiler flag to every implementation file from the library.
Further information can be found here: How can I disable ARC for a single file in a project?

WhiteRaccoon iOS 4.2 errors

I have a app with the WhiteRaccoon framework installed.
I cant compile it as it gives me errors with anything to do with retain or release in WhiteRaccoon.m/h.
Any ideas whats going on?
Thanks.
By the way, I have added the CFNetwork framework. Any ideas?
Your project is probably using ARC and WhiteRaccoon probably isn't.
You can either convert whiteRaccoon (whatever that is) to ARC or exclude the whiteRaccoon files by adding the following compiler flags to it's source files -fno-objc-arc.
To do that click the project on the left hand side then go to the "Build Phases"-> "Compile Sources" look for the white Raccoon .m files and add the -fno-objc-arc under the compiler flags section.
Another option would be to compile the WhiteRaccoon framework into a static library and as this to your project.

iOS project compilation

I am working on a project accessing web service. I found a project
http://d1xzuxjlafny7l.cloudfront.net/downloads/PromoTest.zip
The above code include JSON library [project setting compiler = LLVM 4.2]
And I tried to use partial code of that project in my project.
So I copied the JSON library into my project [my project uses Apple LLVM 3.1]
and then some error show up
eg.
SBJsonStreamWriterState **states;
//error:Pointer to non-const type "SBJsonStreamWriterState *" with no explicit ownership
I have tried using compiler flags -fno-objc-arc, no good.
I wonder if its a ARC problem? if it is, then why above compiler flag wont work.
Try disabling ARC at the target level like shown in the attached picture:
So, I solved it by deleting SBJson Library. I found Apple already written a json library.

How to remove ARC from XCode

I have already created a project in XCode 4.2 with ARC checked. The problem is that I have to download and add the ASIHttpRequest files. This is giving a whole bunch of errors when I try to compile. Is there some way to fix this (other than to create a project again) ?
Click on the name of the project on the navigation view in the left side, go to Targets -> Build Phases and add -fno-objc-arc to the "compiler flags" for any relevant files.
You can turn off ARC per-file by passing the flag -fno-objc-arc to each as they are compiled. Add the flag to the files that need ARC disabled in the Compile Sources group under the target in the project navigator.
Another option would be to compile ASIHttpRequest as its own framework that doesn't have ARC enabled and just link against the framework. Speak of, isn't ASIHttpRequest already in a framework? (I've not looked at it in a while)
Keep using ARC, but disable it for the ASIHttpRequest files. This answer should point you in the right direction:
How can I disable ARC for a single file in a project?

Using an ARC static library in a NON-ARC project

I am trying to get this sorted out. I know how to get an ARC project working with files or static lib's that are not using ARC. For instance, using the compiler flags -fno-objc-arc.
But what if I have a project that is not using ARC and want to include a static library compiled with ARC? Every time I want to build the project it is telling me that it doesn't recognize things like "strong, __unsafe_unretained,...".
To add on to shw's answer. Add -fobjc-arc to compiler flags under build phases to ARC files to make them compile correctly for non-ARC projects.
More info here
It should work fine - are you sure you're using the newest Apple compiler with this non-ARC project and not the GCC one?

Resources