While I personally find Xcode 4’s streamlined interface to be a vast improvement over that of its predecessors, a few less frequently used tasks were moved to places that may not be immediately obvious to anyone who was used to previous versions of the tool. One of the tasks that changed slightly is the method for adding frameworks to a project.

Step One: Our HelloWorld application is going to display a map of the world with annotations indicating the word for hello in major cities around the globe. For this we will need the MapKit framework, which is not included by default.

Step Two: In order to add a framework reference to the project, we need to navigate to the Build Phases tab of the project settings. If you have a code file open, click on the name of your project on the left to get to the project settings. If you have set up custom targets you will want to ensure that you select the target for which you want to add a reference.

Step Three: Under the build phases tab for your selected target there should be a section called Link Binary With Libraries. (If you do not see this section you can click the Add Build Phase button in the lower right and add it.) In this instance you can see that we already have references to UIKit, Foundation and CoreGraphics. To get the reference to MapKit that we need for our project you will have to expand the section and then click on the small ‘+’ symbol in the bottom left corner of the section.

Step Four: After clicking on the ‘+’ symbol a dialog is displayed listing all of the available libraries/frameworks. You could browse the list but in this case we know we are looking for MapKit so it is easier to type that into the search bar at the top, select the name of the framework from the filtered list and click add. If you need to add something which is not available in the list you can choose Add Other… instead and find the source on your disk.

Step Five (optional): The newly added framework will appear on the left at the top of our project list. If you prefer to have it in your Frameworks group you can simply drag it there. Do not worry if its name turns red in the Link Binary With Libraries section on the right after you move it – this is only temporary. The framework will work just fine from within the Frameworks group.

David Brainer-Banker, Software Engineer at eimagine in Indianapolis, IN

Like this post? Share it!