简体   繁体   English

Xcode,在项目之间共享h / m文件?

[英]Xcode, sharing h / m files between projects?

I'm trying to use the same files in different projects. 我正在尝试在不同的项目中使用相同的文件。 I'd like to do this so that I can abstract some testing functionality away from my main project. 我想这样做,以便可以从主项目中抽象出一些测试功能。

However, when I add files from my main project, #include calls in those files are using the files in the main project. 但是,当我从主项目添加文件时,这些文件中的#include调用正在使用主项目中的文件。

eg I have different constant.h files in both projects. 例如,我在两个项目中都有不同的constant.h文件。

I really don't want to create a library / framework. 我真的不想创建一个库/框架。 And I also don't want to have to make changes to the the files specific for one project. 而且我也不想更改一个项目专用的文件。

How can I workaround this? 我该如何解决?

Sharing same physical files in multiple project is not a good idea. 在多个项目中共享相同的物理文件不是一个好主意。 Deleting or modifying from one project might break build for other projects. 从一个项目中删除或修改可能会破坏其他项目的构建。 Moreover you must add all dependent functionalities and source in both projects to build successfully. 此外,必须在两个项目中添加所有依赖的功能和源代码才能成功构建。 Thats how project build works. 那就是项目构建的工作方式。

Suggestion 建议

  1. Always keep separate physical copy for separate projects 始终为单独的项目保留单独的物理副本

  2. Even if you want to reuse physical files, make sure all dependencies are added. 即使您想重复使用物理文件,也请确保已添加所有依赖项。 For example if file A uses file B, to add file A in a project, you must also add file B in the same project even though B has of no use for that project. 例如,如果文件A使用文件B在项目中添加文件A,则即使文件B对该项目没有用处,您也必须在同一项目中添加文件B。

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

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