1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Building a Framework

Discussion in 'Mac Programming' started by Blakeasd, Jun 8, 2011.

  1. macrumors 6502a

    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?
    (I am using Xcode 4)
  2. macrumors 6502a

    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,
  3. macrumors 68000



    1. Menu: Project>Edit Project Settings
    2. Select the "Build" tab
    3. 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.
  4. macrumors 6502a

    I know how to get there, I am not sure what to put though..
  5. macrumors 65816


    You should never need to adjust Header Search Paths when dealing with frameworks, only when dealing with dylibs.

    To create a test a project:
    1. I created a Cocoa Application
    2. I created a Framework subproject
    3. In the build phases of the framework target, I ensured the relevant public headers where in the public part of the copy headers phase
    4. In the build phases of the application target, I added the framework to the target dependencies phase.
    5. 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.
  6. macrumors 6502a

    How did you create the subproject?
  7. macrumors 65816


    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.
  8. macrumors 6502a

    Thanks for your help, I got it working! :)

Share This Page