Corporation Unknown Logo

Adding Frameworks in Xcode 3.1

This is one of those cool little tidbits I learned during a WWDC session and can share now that Xcode 3.1 is out: Xcode 3.1 has changed the way you should add Apple-supplied frameworks. Although Apple claims in the Release Notes (you have read them, haven’t you?) that the process has been “simplified,” the method isn’t really apparent from within Xcode.

Previously, you would add frameworks to the Files panel by selecting the “Existing Frameworks…” item from the “Add” contextual menu, or the “Add to Project…” item of the top Project menu. (These methods are still available in Xcode 3.1.)

'Add > Existing Frameworks' Contextual Menu

Both options bring up a file dialog, allowing you to choose your framework from /System/Library/Frameworks or an SDK subdirectory or anywhere else on your computer. Because of the numerous copies of system frameworks, I have never been completely confident that I’m choosing the correct copy of the framework and won’t run into some really frustrating compatibility bug.

Since Xcode 2.5, Apple has been working to make SDKs more self-contained and swappable. Xcode 3.1 has even added an “Active SDK” submenu next to Active Configuration, Target, Executable and Architecture—you can now dynamically swap between SDK frameworks, but you must avoid the file selection dialog path for frameworks to swap between SDKs.

To use the new method, choose the desired Target (not File Group) and select “Existing Frameworks…” from the “Add” contextual menu. In 3.0 this will give you the same file dialog as before, but in 3.1 it will bring up the Target’s Get Info panel to the General tab. The bottom portion of this pane shows the Target’s Linked Libraries. Clicking the “+” button beneath the list will bring up a list of known frameworks for the active SDK.

The New 'Add Framework' List

Choose from the list and you will not only gain the confidence that you have selected the appropriate version of the framework for your current SDK, but Xcode will be as smart as it can about automatically selecting the appropriate version of the framework if and when you target a different SDK.

(You can also get to this panel by double-clicking the Target, or selecting “Get Info” from the Target’s contextual menu, then selecting the General tab—it’s just more direct from the Existing Frameworks contextual menu item.)

Comments