Adding a framework to XCode 4

of course i did research before posting my question.

I looked at
How to "add existing frameworks" in Xcode 4?
Adding Framework in Xcode 4
Adding an OpenGL framework in Xcode 4
XCode 4 adding dylib

  • XCode 8.2.1 error - No such module YouTubePlayer
  • A Guide for Creating your own Library for Cocoa(touch) development
  • How to build a release version of an iOS framework in Xcode?
  • Required Framework vs Static Library
  • ld: framework not found GRPCClient
  • How to add Private Framework to Target Dependencies?
  • but whole thing is becoming wrong.

    My goal: Add (CorePlot) framework to XCode Mac project (not an iPhone one)

    My environment: OSX Lion 10.7, SDK Lion, XCode 4.1 (4B110)

    My steps:

    • Opened XCode, created new project
    • Downloaded CorePlot into my libraries directory (like ~/Applications/LIBS)
    • Opened project preferences, via (+) opened dialog to add framework
    • Add existing framework (+ copy files to dest. group if needed)
    • Selected directory was ~/Applications/LIBS/CorePlot/Binaries/MacOS/CorePlot.framework/
    • DnD CorePlot to Frameworks Group
    • Added CorePlot to Build Phases > Link Binary with Libraries

    and ran my project

    what I got is this error message:

    dyld: Library not loaded: @loader_path/../Frameworks/CorePlot.framework/Versions/A/CorePlot
    Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/metralight-hjuvuwlhgohrtdeepvcymnsaxomc/Build/Products/Debug/
    Reason: image not found

    And in fact, when I looked into given directory (app bundle) there was no directory Frameworks and so the linking cannot be successful

    I have searched one more, and found, that I can create Build Rule and copy files into final binary bundle via some script, but is this only way how to do this?

    Isn’t there some option to just turn on/off copying linked frameworks to final bundle?

    Note that CorePlot target ‘.framework’ has Dynamic Library Install Name set to @loader_path/../Frameworks/CorePlot.framework/Versions/A/CorePlot, so it is looking in right place in final binary bundle

    2 Solutions Collect From Internet About “Adding a framework to XCode 4”

    After adding framework via “Add existing framework”

    • Go to Project Settings > Build Phases
    • In right bottom corner click Add buid phase > Copy Files
    • Select Destination > Frameworks
    • Drag&Drop framework to files list

    And that’s it.

    Another important detail here – you must have the “Runtime search path” to be defined in the projects, it’s empty by default.

    Something like this:

    LD_RUNPATH_SEARCH_PATHS = @loader_path/../Frameworks