Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 AFNetworking 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 AFNetworking somehow. I'm not sure I was able to download it in the correct form -- it seems all I could get was the AFNetworking 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 CocoaPods, 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 AFNetworking just to see if they worked (but of course they don't -- I think I need some sort of .framework file).

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

like image 282
James Dunn Avatar asked Jan 22 '14 18:01

James Dunn


2 Answers

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.

like image 150
Michael Dautermann Avatar answered Oct 27 '22 06:10

Michael Dautermann


Use pods, than you wont have to upload AFNetworking to your github project, and there is no worry about wrong linkers etc.

Use pods: install pods

Instalation AFNetworkign with pods: install AFNetworking

like image 28
edzio27 Avatar answered Oct 27 '22 07:10

edzio27