How to add Core Foundation framework in Xcode 4 to a bare Command Line Tool if frameworks list is empty?

10,636

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.

Share:
10,636
Warren  P
Author by

Warren P

Software Developer: Web, Desktop, and Server service developer JavaScript (ExtJS/SenchaTouch/jquery), HTML5, CSS C#/ASP.NET MVC/ASP.NET Core/Roslyn/Visual Studio 2015 Delphi/ObjectPascal C (Linux and others) and Objective-C (have an app in the app store) Python C++ Smalltalk/Pharo/Squeak Embedded Systems, and cross-platform stuff (Windows, Linux, Mac OS X) नमस्ते. मैं हिंदी फिल्मों से प्यार है. Bits of code at Bitbucket hosting: https://bitbucket.org/wpostma More bits of code at Github: https://github.com/wpostma

Updated on June 04, 2022

Comments

  • Warren  P
    Warren P almost 2 years

    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.)