PDA

View Full Version : Building a Framework




Blakeasd
Jun 8, 2011, 04:24 PM
Hello,
I downloaded a framework off the internet and it came in the form of an Xcode project. The target of the project I downloaded is a framework, I am trying to get the .framework and add it to my own project for use. I tried the Build > Archive the project, but nothing appeared in the Organizer. How do I get the .framework file?
Thanks
(I am using Xcode 4)



Blakeasd
Jun 8, 2011, 06:57 PM
I just found some Apple documentation that says I can just add the framework Xcode Project to my App's Xcode project. I did this but I don't know how to do one step:
From Apple Documentation:

In your application project, modify the Header Search Paths setting of the application target by adding the directories containing any framework header files.


I know where I set this, but I am not sure what the directory would be.
Please Help,
Thanks

Sydde
Jun 8, 2011, 08:23 PM
I just found some Apple documentation that says I can just add the framework Xcode Project to my App's Xcode project. I did this but I don't know how to do one step:
From Apple Documentation:


I know where I set this, but I am not sure what the directory would be.
Please Help,
Thanks



Menu: Project>Edit Project Settings
Select the "Build" tab
Scroll about halfway down, to "Search Paths"


Of course, if you have the source, you could just copy the files you need into your project and build them right in, though the ethicality of that is somewhat dubious.

Blakeasd
Jun 8, 2011, 09:03 PM
I know how to get there, I am not sure what to put though..
Thanks

jiminaus
Jun 9, 2011, 05:09 AM
You should never need to adjust Header Search Paths when dealing with frameworks, only when dealing with dylibs.

To create a test a project:

I created a Cocoa Application
I created a Framework subproject
In the build phases of the framework target, I ensured the relevant public headers where in the public part of the copy headers phase
In the build phases of the application target, I added the framework to the target dependencies phase.
Then I added the framework into the link binary with libraries phase.


Note that, as per usual with framework, you need to prefix the name of the framework when importing header files from it. For example, the framework is called MyFramework and you want to import MyClass.h, you need to import MyFramework/MyClass.h.

Also this setup will only work in your development environment. There's extra work to do to embed the framework inside your app bundle before distribution. But worry about that closer towards release.

Blakeasd
Jun 9, 2011, 09:52 AM
How did you create the subproject?

jiminaus
Jun 9, 2011, 03:39 PM
How did you create the subproject?

Right-click/control+click the parent project, then Add Project.

If you already have a project, right-click/control+click the parent project, then Add Files, choose the sub-projects .xcodeproj file.

Alternatively create a workspace containing the 2 projects. It's not critical to have a parent/child relationship between the projects.

Blakeasd
Jun 9, 2011, 05:34 PM
Thanks for your help, I got it working! :)