TJamesBoone TJamesBoone - 3 months ago 6x
iOS Question

How to add AFNetworking to XCode app

I'm relatively new to XCode and iOS. My background for understanding how to add libraries/dependencies to a project is in the world of Java and Maven.

I need to add AFNetworking to my project and have been unable to do so successfully.

First, I tried going to

my project -> Build Phases -> Link Binary
With Libraries, clicking the "+" button, and then search for
from the list. It wasn't in the list.

So, I figured I'd have to add it using the "Add Other..." option. Which means, of course, I'd need to download
somehow. I'm not sure I was able to download it in the correct form -- it seems all I could get was the
project itself, rather than a framework (if I understand correctly, frameworks are analogous to jars? Can you generate a framework by building an iOS project in a certain way?). I downloaded it from their GitHub page. (I also tried their "Getting Started" guide, but it had me using
, which I couldn't get to work right and I'd rather avoid it for now.)

I've tried adding project files and folders from
just to see if they worked (but of course they don't -- I think I need some sort of

Bottom line: I can't seem to find a way to add
to my project. How can I do it?


It sounds like you got the first part down, which is downloading it from the GitHub page.

When I follow this tutorial, it shows how they imported AFNetworking into their own sample project (that is, you'll see a "AFNetworking" group in the list of files and folders along the left side of your Xcode window).

Once AFNetworking is building along with the rest of your code in your project, you should be able to call into the various AFNetworking API's from your code. You'll need to make certain to add in the appropriate "#import "AFNetworking.h"" lines into your source code files from which you'll be calling AFNetworking.