简体   繁体   English

在XCode中添加到目标和添加到项目之间的区别

[英]Difference between add to target & add to project in XCode

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/iPhoneUnitTesting is says add blahblah.m file to your target & add blahblah.m file to your project. 我正试图在此页面上将Google Toolbox for Mac用于单元测试目的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... 有什么区别,我应该如何添加目标......

In order to "Add to project" you simply have to drag the file into Xcodes sidebar. 要“添加到项目”,您只需将文件拖到Xcode的侧边栏中即可。 Eventually it should look like this: 最终它应该是这样的:

Xcode侧边栏截图

"Add to target" means that the file has to be in the "Compile Sources" group of your LogicTests-target. “添加到目标”表示该文件必须位于LogicTests目标的“编译源”组中。

Xcode目标截图

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: 您还可以通过查看“详细信息”面板中的右侧复选框来检查文件是否已添加到当前活动目标:

Xcode细节面板

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文件添加到单元测试运行目标而不是实际的应用程序目标,这样它们就不会被编译到您的应用程序中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM