简体   繁体   English

在Xcode / iOS项目之间共享文件

[英]Sharing a File Among Xcode / iOS Projects

I have several iOS apps that rely on a common class (ie MyClass.swift). 我有几个依赖于通用类(即MyClass.swift)的iOS应用。 Rather than copy MyClass.swift into each project subdirectory, I would like to configure Xcode to understand that the file resides on my desktop but should be considered an essential part of each project for developing, building, running on simulator, running on device, archiving, and uploading to the App store. 与其将MyClass.swift复制到每个项目子目录中,我不希望将Xcode配置为了解该文件位于我的桌面上,但应将其视为每个项目的重要组成部分,以用于开发,构建,在模拟器上运行,在设备上运行,存档,然后上传到App Store。

Is it possible to achieve this without using a Library, Framework, or third-party dependency manager? 是否可以在使用库,框架或第三方依赖项管理器的情况下实现这一目标?

i usually create a separate repository for the common class. 我通常为通用类创建一个单独的存储库。 when adding the common class to other projects i make sure to deselect "Copy items if needed". 将通用类添加到其他项目时,请确保取消选择“根据需要复制项目”。

now each project points to the same file and any changes made by a project to the common class immediately changes the code for all projects. 现在,每个项目都指向同一个文件,并且项目对通用类所做的任何更改都会立即更改所有项目的代码。 changes made to the common class should be committed to its own repo. 对普通类所做的更改应提交给自己的仓库。

this approach has some downsides (repositories for the separate projects would require you to manually pull down the common class's repo), but these could be mitigated by using submodules 这种方法有一些缺点(单独项目的存储库需要您手动拉下公共类的存储库),但是可以通过使用子模块来缓解这些问题

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

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