jtbandes
jtbandes

Reputation: 118671

Target Dependency between two projects in the same workspace

I'm using Xcode 4.3 to create a framework for OS X. I created a workspace and a project (with a framework target) to go in this workspace.

Now, I want to include & link with a third-party framework which I've also added to the same workspace (but not within my project). I clicked the + button in the "Link Binary With Libraries" build phase, and the third-party framework simply appeared in the list of available libraries.

The linked framework shows up red in the Project navigator, as the third-party library has not been built yet (confusingly, though, my project successfully builds — although I'm not yet trying to use the third-party framework):

I was going to solve this by adding it as a Target Dependency, but when I click + on the "Target Dependencies" build phase, the third-party target doesn't show up in the list.

How should I properly configure/resolve this dependency? Also, do I need to create a Copy Files build phase to ensure the framework is copied into my target's Frameworks directory? How would I set that up properly?

Upvotes: 12

Views: 9388

Answers (1)

rsebbe
rsebbe

Reputation: 334

I ran into something similar but with static libs.

  • Do what you did to build the framework, build your app (even if it fails, the framework should build)
  • Remove the reference to the framework in your app target's link build phase
  • Locate the built framework in the Finder (the one built by your app workspace).
  • drag/drop it into the app project that uses it. Notice that this time it appears with black color (not red)
  • click it, and make sure the Xcode inspector shows "relative to built products" (you may need to change it reference type), and that the path is just the myframework.framework.
  • check that it has been added to the app link phase (it should)
  • that's the one you can use in the copy/build phase.

Upvotes: 10

Related Questions