Building a Framework

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

  1. macrumors 6502a

    Joined:
    Dec 29, 2009
    #1
    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)
     
  2. thread starter macrumors 6502a

    Joined:
    Dec 29, 2009
    #2
    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
     
  3. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #3

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

    Joined:
    Dec 29, 2009
    #4
    I know how to get there, I am not sure what to put though..
    Thanks
     
  5. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #5
    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. thread starter macrumors 6502a

    Joined:
    Dec 29, 2009
  7. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #7
    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. thread starter macrumors 6502a

    Joined:
    Dec 29, 2009

Share This Page