Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Target dependencies vs. Link binary with libraries

Tags:

xcode

I don't understand the difference between these Xcode features.

I'm building and app - but the functionality of the app is being abstracted into libraries (so they can be distributed separately as an "SDK").

So I have a workspace of library projects and the app project. I can add library projects to the app project by doing "link binary with libraries". This gives me a list of .a library projects in the current workspace which I can link to.

I can also add frameworks here.

In the "target dependencies" bit all I can add is other targets in the current project.

What I really want to do is both - I want my app project to build all the other library projects when I build it. I also want to make it verbose what libraries the app (and other libraries) depend on.

So can somebody please explain the difference, and whether what I am doing is the right way to go about it?

Many thanks!

like image 791
Thomas Clayson Avatar asked Oct 17 '12 09:10

Thomas Clayson


1 Answers

It says here...

  1. Drag your framework product (located in the Products folder) to the existing Link Binary With Libraries build phase of your application target. This causes the application to link against your framework.

And...

  1. In the General tab of the inspector window, add your framework as a dependency for the application. Adding this dependency causes Xcode to build the framework target before building the application target.

The build dependency you establish in the application target causes the framework to be built before the application. This is important because it guarantees that a built version of your framework will be available to link against and to embed in the application. Because of this dependency, you can set the active target of your Xcode project to your application and leave it there.

So it seems that you're supposed to use both. Seems redundant though, because if you're linking to a framework then its a dependency. I suppose you might want to only link to a library and not build it first. Although XCode seems to build linked libraries even without them being added to the dependency section. Perhaps that's a result of the "Find Implicit Dependencies" option in a scheme's build settings.

like image 160
Ian Warburton Avatar answered Oct 05 '22 11:10

Ian Warburton