在 XCode 中添加到目标和添加到项目之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3959311/
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
Difference between add to target & add to project in XCode
提问by Asad Khan
I am trying to inegerate Google Toolbox for mac for unit testing purposes on this page http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTestingis says add blahblah.m file to your target & add blahblah.m file to your project.
我正在尝试在此页面上为 mac 的 Google 工具箱进行单元测试http://code.google.com/p/google-toolbox-for-mac/wiki/iPhoneUnitTesting是说将 blahblah.m 文件添加到您的目标 &将 blahblah.m 文件添加到您的项目中。
What is the difference, how should I add to target...
有什么区别,我应该如何添加到目标...
回答by Chilloutman
In order to "Add to project" you simply have to drag the file into Xcodes sidebar. Eventually it should look like this:
为了“添加到项目”,您只需将文件拖到 Xcodes 侧栏中。最终它应该是这样的:
"Add to target" means that the file has to be in the "Compile Sources" group of your LogicTests-target.
“添加到目标”意味着该文件必须在 LogicTests 目标的“编译源”组中。
You can also check if a file has been added to the currently active target by looking at the right Checkbox in the "Detail" panel:
您还可以通过查看“详细信息”面板中的右侧复选框来检查文件是否已添加到当前活动的目标中:
回答by Nimrod
Do "Get Info" on the file after dragging it into your project. You'll see checkboxes for each target. Just check the checkbox, or make sure it's checked, to make sure it's added to your target.
将文件拖入项目后,对其执行“获取信息”。您会看到每个目标的复选框。只需选中复选框,或确保选中它,以确保将其添加到您的目标中。
Adding something to the project usually, depending on the file type, automatically adds it to all targets that make sense.
通常,根据文件类型,将某些内容添加到项目中会自动将其添加到所有有意义的目标中。
Adding a file to a target tells the build system that the target depends on that file and that the file should be incorporated into the target build somehow. In the case of resources they're simply copied into the application bundle. In the case of .m files, they're compiled and linked.
将文件添加到目标告诉构建系统目标依赖于该文件,并且该文件应该以某种方式合并到目标构建中。对于资源,它们只是简单地复制到应用程序包中。对于 .m 文件,它们被编译和链接。
I'm not familiar with Google Toolbox, but chances are that for unit testing you want your unit test .m files to be added to your unit test-running target and not your actual application target so they don't get compiled into your app.
我不熟悉 Google Toolbox,但是对于单元测试,您可能希望将单元测试 .m 文件添加到您的单元测试运行目标而不是您的实际应用程序目标,这样它们就不会被编译到您的应用程序中.