XCode 3.1, iPhone SDK - adding a framework

Discussion in 'Mac Programming' started by drivefast, Apr 5, 2008.

  1. drivefast macrumors regular

    Mar 13, 2008
    there's gotta be something goofy that i do here, i cant belive it wouldnt work. i need to add the security framework to my project. so i ctrl+click on the Frameworks / Linked Frameworks, Add -> Existing Frameworks, and i select the security framework for the iphone simulator platform, sdk, blah-blah. this also adds my framework to Targets / My Project / Link Binary with Libraries. i check to make sure the auto-added frameworks, like the foundation, are pretty much on the same path as the newly added security, so it looks like everything's consistent.

    back to my project, i add the #import line for the header of the newly added framework, then try to use a C function and a constant which are declared in the header file. when i try to build, the compiler complains that the constant is not recognized. (if i remove the #import line - same effect.) if i replace the constant with its actual (numeric) value, the compile is successful, but tle link editor complains that my function name is an unrecognized symbol.

    now if i do all this thing again with the address book framework instead of the security framework, using same platform, same sdk, same directories - everything works.

    it drives me nuts. of course i verified the name of the header file, directory names and so on. if i expand the framework line on the left "groups and files" pane, the expected header files are shown. any idea what else i should check?... thank you for the advices.
  2. sabross macrumors newbie

    Jun 3, 2008
    Similar problem

    I'm wondering if you solved your problem.

    My problem is similar, I:

    1. Link framework in Frameworks folder using existing Framework
    2. Choos AddressBook.framework
    3. Add #import <AddressBook/AddressBook.h>
    4. Intellisence detects things like "ABPerson"

    but then it seems that the reference is not been completed, cause if I try:

    ABAddressBook *ab = [ABAddressBook sharedAddressBook];

    "ABAddressBook Undeclared" and as well for every AB* class.

    What am i missing?


  3. logix812 macrumors newbie

    Jun 6, 2008
    I have the same situation

    1: Build the Framework (Install Path set to @executable_path/../Frameworks)
    2: Add to iPhone App, XCode adds it in all the usual places
    3: Add a new Copy Files Build Phase (Placing MyFramework.framework into the phase. Set the Drop-Down to Frameworks)
    4: #import <MyFramework/MyFramework.h> (code completion knows it's there)
    5: Build the app (no error)
    6: Build and Run the App (dyld: Library not loaded:... blah blah blah)
    7: Set the path type of the framework to Relative to Project or Relative to Current SDK (Since i am using the simulator).
    8: Build and Run (dyld: Library not loaded:... blah blah blah)

    Does the iPhone allow embedded Frameworks? What am I doing wrong?
  4. logix812 macrumors newbie

    Jun 6, 2008
    I have also tried the following:
    using @loader_path/../Frameworks instead of @executable_path/../Frameworks

    And I have tried setting the Base SDK of the framework to Simulator - iPhone OS 2.0, but that just gives me this error when trying to build:

    target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform

    Same error if I set the Base SDK to Device - iPhone OS 2.0 ( I figured that would fail, but for the sake of completeness I gave it a whirl)
  5. firewood macrumors 604

    Jul 29, 2003
    Silicon Valley
    I had to use the Finder to view the directory containing the existing frameworks, and manually drag the framework I wanted into the XCode project tab. That got rid of my link errors. Using the menu to add didn't work.
  6. fredyX macrumors newbie

    Oct 17, 2009
    HERE a little help for add frameworks in Xcode
    "...To add frameworks, select the ContactMapper target (in the Targets group), right-click
    it, and choose Get Info. In the General tab, hit the + button at the bottom of the screen,
    choose the two frameworks, and click the Add button. .."

Share This Page