简体   繁体   English

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

[英]how do I reference a separate project in xcode 4?

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 我尝试将现有的“Hello World”xcode项目文件复制到我的项目中,但这似乎不起作用
  • Do I need to create a new "Target" based on "coco touch static library" option? 我是否需要基于“coco touch static library”选项创建新的“Target”?
  • 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? 我需要在项目方面做些什么 - 应该去添加文件,选择扩展Xcode项目文件就足够了?

thanks 谢谢

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). 在这个阶段,分离你想要的位可能是一个高级主题(取决于lib的布局/依赖)。 you should prefer to reference and link because it will normally minimize your maintenance time, especially if you use it in multiple projects. 您应该更喜欢引用和链接,因为它通常会最小化您的维护时间,尤其是在多个项目中使用它时。

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 static library”选项创建新的“Target”?

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. 从上面概述的过程开始。

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. 但是,如果您不仅仅有几个文件,并且您认为不会更改代码,那么创建静态库可能是最佳选择。

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

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