How to add a framework to your project in xcode 4

When I googled for this, I got false information — so here is how you do it:


1) First click the Blue Xcode icon signifying your project on the lefthand navigation pane.


Confused? The highlighted thing:



2) Now look right, to the next pane. Make sure the project name under TARGETS is selected, not PROJECTS.


Looks like this:



3) Next pane on the right, you’ll see a few things at the top, “Summary”, “Info”, “Build Settings”, “Build Phases”, “Build Rules” … You want to click on Build Phases.


You will see a few expandable sections now.


4) Expand the section labeled Link Binary With Libraries


You should now be seeing something that looks like this:



5) Click the + button at the bottom-left of that Link Binary With Libraries section


Select the library you want, for example, AVFoundation.framework and click Add.


You’ll notice the library/framework has appeared in your navigation pane at the left.


You can go ahead and drag that into the Frameworks folder.


6) In order to utilize the framework, you will need to #import it into your source code.


For AVFoundation.framework, I simply put the following line in my main.m, right under the existing #import for UIKit



#import <AVFoundation/AVFoundation.h>



And that worked for me.