8

I created a new command line tool (the way to create a Mac OS X command line app) using Xcode 4.5, but I now want to add a framework to it. The frameworks list in the build phases is empty.

I can add .h/.m objective C class header and implementation files that I have written but I don't know how to make a "Command Line Tool" into what the old Xcode probably had a different template for; A command line application (not Cocoa app) which can access Core Foundation framework, or any other framework I choose to add to it.

Also, there used to be a "Core Foundation Tool" option in Xcode 3, where is it now?

(Update: I was clicking "+" inside Target Dependencies, which seemed sensible, but which gives me only an empty list of things to add. I figured there must be something somewhere else you had to change to make things show up in Target Dependencies, which if I may say, is not exactly clear to new users. Thus this public service message, question, and answer. Hey Apple, how about you change this to "Link libraries or Frameworks" so that the word Framework shows up there. Making us guess if we're adding a library or a dependency when the only word we know about is Framework, is confusing.)

pkamb
  • 33,281
  • 23
  • 160
  • 191
Warren P
  • 65,725
  • 40
  • 181
  • 316
  • 'target dependencies' is for dependencies between targets. I.e., when one target depends on another target in the same project. – bames53 Jan 07 '13 at 19:26
  • In my opinion that shouldn't be the first item in this list, unless 99% of users use that, and not adding frameworks. With how common it is to add quartzcore to apps, I think the Frameworks list should be first. The first item in the list should be the one most commonly used. Instead, it's third, after a list of sources that are compiled (which duplicates the main project view on the left side), and which sadly, is missing the all important word "Frameworks". Apple should think of the newbies, sigh. – Warren P Jan 07 '13 at 19:37

1 Answers1

10

Go to the "Link Binary with Libraries" option and click +. It's found on the Build Phases page of your main Xcode project settings. You might want to collapse the Target Dependency and Compile Sources sections, so that the Link Binaries section is fully visible on your screen.

enter image description here

Footnote:

My mistake was clicking "+" in the Target Dependencies section, which was where I thought I might "add a dependency on CoreFoundation", which isn't what you do. I also found it confusing that you Link Binary with Libraries, when I thought that Xcode didn't use Framework and Library terms interchangeably, and in this case, confusingly. It also doesn't help that the plus icon is hidden and you have to scroll to access it, or else collapse the two top sections. Xcode is full of "User Interface is very confusing" areas, in my opinion:

enter image description here

Also, add #import <CoreFoundation/CoreFoundation.h> to your implementation (.m) files, as needed.

pkamb
  • 33,281
  • 23
  • 160
  • 191
Warren P
  • 65,725
  • 40
  • 181
  • 316