如何在工作区中的两个xcode项目之间共享文件? [英] How to share files between two xcode projects in workspace?

查看:115
本文介绍了如何在工作区中的两个xcode项目之间共享文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解了Xcode工作区.我知道如何共享静态库,但是我想在工作区中的两个xcode项目之间共享文件,并且可以一次运行多个目标吗?能否向我提供有关如何进行操作的信息?为此.

I learnt about Xcode workspace .I know how to share the static library but i want to share the files between two xcode projects in workspace and is it possible to run multiple targets at a time?Can you provide me the information of how to do this.

预先感谢

推荐答案

即使在相同级别的项目(没有子项目)下,在相同工作空间中的项目之间共享文件也很容易:

Sharing files between projects in the same workspace is easy, even if the projects are on the same level (no subprojects):

假定您要在Project1Project2之间共享常量,并且这些常量在文件SharedConstants.swift中定义,该文件在Project1中定义.
为了在Project2中使用,必须在此处进行编译.

Assume you want to share constants between Project1 and Project2, and these constants are defined in a file SharedConstants.swift, which is defined in Project1.
In order to be used in Project2, it must be compiled there.

因此,在项目导航器Project2中激活,选择目标并打开Build Phases选项卡.
点击左侧的小三角形,在此处打开Compile Sources.

Thus, activate in the project navigator Project2, select the target and open the Build Phases tab.
Open there Compile Sources by tapping the little triangle left.

点击此目标的所列来源下方的+按钮.这将显示Project2的文件列表.在那里,您无法选择共享常量,因为它们不属于该项目.
但是,左下方是一个按钮Add other…
轻击它会打开一个标准文件选择窗口,您可以在其中从Project1中选择SharedConstants.swift.

Tap the + button below the listed sources for this target. This will show you a list of files of Project2. There you cannot select your shared constants, because they do not belong to this project.
However left bottom is a button Add other…
Tapping it will open a standard file selection window where you can select SharedConstants.swift from Project1.

点击Open后,将打开第二个窗口,其中带有Destination: Copy items if needed复选框.

After tapping Open, a 2nd window opens with a Destination: Copy items if needed checkbox.

重要提示:请勿选中此框!

如果要进行检查,则在Project2中将使用SharedConstants.swift副本,并且在Project1中所做的任何更改都不会显示在Project2中.取而代之的是,您取消选中它,在Project2中仅使用对Project1中的SharedConstants.swift引用,并且任何更改都会影响这两个项目.

If you would check it, a copy of SharedConstants.swift would be used in Project2, and any changes that you make in Project1 would not be visible in Project2. Instead, it you uncheck it, only a reference to SharedConstants.swift in Project1 would be used in Project2, and any changes will affect both projects.

这篇关于如何在工作区中的两个xcode项目之间共享文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆