我如何在 xcode 4 中引用一个单独的项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5372761/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:35:08  来源:igfitidea点击:

how do I reference a separate project in xcode 4?

iphoneobjective-cxcodexcode4project-reference

提问by Greg

How do I reference another project which has code I wish to leverage in XCode 4. In particular I'm trying to make use of the NSDate extensions from here.

我如何引用另一个项目,该项目具有我希望在 XCode 4 中利用的代码。特别是我试图从这里使用 NSDate 扩展。

Some notes:

一些注意事项:

  • I was assuming I should probably reference rather than trying build a framework
  • I tried copying the existing "Hello World" xcode project file across into my project, however this didn't seem to work
  • Do I need to create a new "Target" based on "coco touch static library" option?
  • Then would I need to Edit the current Product Scheme so that when I build the new target would build
  • What do I need to do on my project side exactly - should going Add Files, and choosing the extensions Xcode Project File be enough?
  • 我假设我应该参考而不是尝试构建一个框架
  • 我尝试将现有的“Hello World”xcode 项目文件复制到我的项目中,但这似乎不起作用
  • 我是否需要基于“coco touch 静态库”选项创建一个新的“目标”?
  • 那么我是否需要编辑当前的产品方案,以便在我构建新目标时会构建
  • 我需要在我的项目方面做些什么 - 应该添加文件,并选择扩展 Xcode 项目文件是否足够?

thanks

谢谢

采纳答案by justin

I was assuming I should probably reference rather than trying build a framework

我假设我应该参考而不是尝试构建一个框架

yes, reference and link with it, unless you need only a bit of it. at this stage, separating the bits you want may be an advanced topic (depends on the lib's layout/depends as well). you should prefer to reference and link because it will normally minimize your maintenance time, especially if you use it in multiple projects.

是的,参考并链接它,除非你只需要一点点。在这个阶段,分离你想要的位可能是一个高级主题(取决于 lib 的布局/也取决于)。您应该更喜欢引用和链接,因为它通常可以最大限度地减少您的维护时间,尤其是当您在多个项目中使用它时。

I tried copying the existing "Hello World" xcode project file across into my project, however this didn't seem to work

我尝试将现有的“Hello World”xcode 项目文件复制到我的项目中,但这似乎不起作用

you don't create a project, you add the library's xcode project to your app or library, set the lib as a dependency, add the library to your search paths if needed, then link with the library.

您不创建项目,而是将库的 xcode 项目添加到您的应用程序或库中,将 lib 设置为依赖项,如果需要将库添加到您的搜索路径,然后与库链接。

Do I need to create a new "Target" based on "coco touch static library" option?

我是否需要基于“coco touch 静态库”选项创建一个新的“目标”?

no

Then would I need to Edit the current Product Scheme so that when I build the new target would build

那么我是否需要编辑当前的产品方案,以便在我构建新目标时会构建

no. you configure it as a dependency. you may need to alter the lib's build settings if there is a major conflict, which the linker or compiler would point out.

不。您将其配置为依赖项。如果存在重大冲突,您可能需要更改 lib 的构建设置,链接器或编译器会指出这一点。

What do I need to do on my project side exactly - should going Add Files, and choosing the extensions Xcode Project File be enough?

我需要在我的项目方面做些什么 - 应该添加文件,并选择扩展 Xcode 项目文件是否足够?

start with the process outlined above.

从上面概述的过程开始。

回答by drewag

There is no reason to bring in an actually project. Either you can bring in the source files themselves and you could even use the same exact files instead of copying them if you want. However, if you have more than just a few files, and you don't think you will be changing the code much, then creating a static library would probably be the best option.

没有理由引入一个实际项目。您可以自己引入源文件,甚至可以使用完全相同的文件,而不是根据需要复制它们。但是,如果您有多个文件,并且您认为不会对代码进行太多更改,那么创建静态库可能是最佳选择。