Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 307
jtbandes Avatar asked Apr 22 '12 01:04

jtbandes


People also ask

What is target dependency?

A dependency is another target that must be built before the current target can be. For example, if you have an app target and a framework target, the app target can have the framework target as a dependency, to ensure that the framework is built first. That is, the app target "depends" on the framework.

What is the difference between project and target in Xcode?

A target defines a single product; it organizes the inputs into the build system—the source files and instructions for processing those source files—required to build that product. Projects can contain one or more targets, each of which produces one product.


1 Answers

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.
like image 128
rsebbe Avatar answered Sep 24 '22 07:09

rsebbe