如果框架列表为空,如何将 Xcode 4 中的 Core Foundation 框架添加到裸命令行工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14202366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add Core Foundation framework in Xcode 4 to a bare Command Line Tool if frameworks list is empty?
提问by Warren P
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.
我使用 Xcode 4.5 创建了一个新的命令行工具(创建 Mac OS X 命令行应用程序的方法),但我现在想向它添加一个框架。构建阶段中的框架列表是空的。
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.
我可以添加我编写的 .h/.m 目标 C 类头文件和实现文件,但我不知道如何将“命令行工具”制作成旧 Xcode 可能具有不同模板的内容;可以访问 Core Foundation 框架或我选择添加到其中的任何其他框架的命令行应用程序(不是 Cocoa 应用程序)。
Also, there used to be a "Core Foundation Tool" option in Xcode 3, where is it now?
另外,Xcode 3 中曾经有一个“ Core Foundation Tool”选项,现在在哪里?
(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.)
(更新:我在 Target Dependencies 中单击了“+”,这似乎很合理,但它只给了我一个要添加的空列表。我认为必须在其他地方进行更改才能使 Target Dependencies 中的内容显示出来,如果我可以说,新用户并不完全清楚。因此,这个公共服务消息、问题和答案。嘿Apple,你如何将其更改为“链接库或框架”,以便框架一词出现在那里。当我们知道的唯一词是框架时,让我们猜测是添加库还是依赖项,这很令人困惑。)
回答by Warren P
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.
转到“将二进制文件与库链接”选项,然后单击 +。它位于主要 Xcode 项目设置的 Build Phases 页面上。您可能希望折叠 Target Dependency 和 Compile Sources 部分,以便 Link Binaries 部分在屏幕上完全可见。
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:
我的错误是单击“目标依赖项”部分中的“+”,在此我认为我可能会“添加对 CoreFoundation 的依赖项”,这不是您所做的。当我认为 Xcode 没有互换使用框架和库术语时,我还发现将二进制与库链接起来很令人困惑,在这种情况下,令人困惑。加号图标被隐藏并且您必须滚动才能访问它也无济于事,否则折叠顶部的两个部分。在我看来,Xcode 充满了“用户界面非常混乱”的地方:
Also, add #import <CoreFoundation/CoreFoundation.h>
to your implementation (.m) files, as needed.
此外,#import <CoreFoundation/CoreFoundation.h>
根据需要添加到您的实现 (.m) 文件中。