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.

Upgraded to xcode 4 could not insert new outlet

Are you following along on Apple’s “Your First iOS Application” guide, found here ?

Did you upgrade to Xcode 4 mid way? Now when you try to create an outlet, and it says it “could not insert new outlet” in scary red letters; something about not know what class you are looking for.

But… my application builds! What the hell?

Confusing, yes, but this worked for me:

1) Go to your helloWorldAppDelegate.m file

2) You’ll see this code:

@synthesize myViewController;

or you might see

@synthesize myViewController=_myViewController;

3) If it is like the first example, change it to look like the 2nd one. If it is like the 2nd one, change it to look like the first.

4) Make sure the memory release is correct in your dealloc method at the bottom of the same file. If you changed the @synthesize to look like the 2nd example, make sure the release looks as such:

[_myViewController release];

And vice versa.

5) Build, simulate. If it works, try making the connection again from your nib file to your header file. At this point it worked for me.

Oddly enough, once it worked, I was able to reverse the changes in the helloWordAppDelegate.m file without any problems. Clearly this was just a bug in transitioning from Xcode 3 to Xcode 4.

Keep in mind that the two different ways of synthesizing that class variable is simply a matter of stylistic concern. In the earlier pages of the guide, it is explained that the underscore in _myViewController is to “remind you that you’re not supposed to access class variables directly “

Learning ios development for free

Learning iOS Development for Free

There are a lot of great lectures on learning iOS development on the iTunesU network free for download. But it’s slow going and I’d rather code than watch lectures about it.

This guy has a bunch of links and this is where I’ve started a few days ago with iOS.


“Can you recommend a good book for getting started with Objective-C?”

I get this question a lot, but there’s no need to spend any money or even to spend time digesting an entire book. I always point people to the Apple docs — the documentation is very modular and (mostly) very reliable.