How to install static frameworks on Xcode 4

I had some issues installing OCMock on Xcode 4, and found the method to be documented differently in a number of places. Fortunately I’ve worked out how to do it and it can be applied to any static framework, so I’m sharing it here, using OCMock as an example.

Download the framework and locate the .a and header files

Download the distribution files for the framework (for OCMock it comes as a dmg) and locate the .a and header files.

Here’s mine on my desktop:

Copy these files into your source folder for your Xcode project

When you are done your structure should look something like this:

 

Create references to the files in Xcode 4

To set up references to these new files:

You should now see the framework listed.

My project folder now looks like this:

I’ll add any more headers from other Frameworks ¬†in subgroups with the name of the framework.

Add your header search path to the target build settings

Note: if you didn’t place your framework files into the Libraries folder, it should point to whatever¬†{LIBRARIES_FOLDER} is. Because you selected recursive, it will search down until it locates the headers.

Add linker flag

Restart Xcode and you should be done!

Restart Xcode.

Leave any issues in the comments and I’ll see what I can do.

2 Comments

Erik

Hi Mark,

Thanks for sharing this. I came across it while trying to find a solution to a different question. I don’t suppose you’d care to layout a similar explanation for setting up a dynamic framework layout would you? I’m trying to get XCode4 to behave while I set up a framework for plugins and my app keeps barking about the framework depending upon itself.

Cheers,
Erik

kirby.mark

Hey Erik, I’ve not had any luck with dynamic frameworks, although I know you are encouraged to use workspaces. Any progress I make I shall certainly document here.

Leave a comment: