在 Xcode 项目之间共享类 [英] Sharing classes between Xcode projects
问题描述
不久前,我使用 Xcode 开发了一个 iOS 应用程序,并创建了一堆协同工作以与 RESTful API 通信的类.现在我正在创建第二个应用程序,完全独立但使用相同的 API 进行通信.我想重用这些类,解决这个问题的最佳方法是什么?我应该通过一些版本控制系统来做吗?还是应该使用 Xcode 工作区?
A while ago I developed an iOS application using Xcode that and created a bunch of classes that work together to communicate with a RESTful API. Now I'm creating a second app, totally separate but communicates with the same API. I want to reuse these classes, what is the best way to approach this? Should I be do the via some Version control system? Or should I use an Xcode workspace?
在此先感谢您的帮助.
推荐答案
在类似的情况下,我使用 XCode 工作区和静态库完成.
In similar situation I done it using XCode Workspace and Static Library.
我将公共类添加到静态库项目并将其添加到 XCode 工作区.在我的第二个项目中,我添加了静态库项目.
I added the common classes to a Static Library project and added that to the XCode Workspace. In my second project I added that Static Library Project.
我有两个选择:
- 将该静态库项目添加到新项目工作区
- 将静态库 (.a) 项目添加到新项目
我选择第一个选项是因为,我可以将其他常用文件添加到该静态库中,还可以根据需要修改现有文件.
I chose the first option because, I can add the other common files to that Static Library and also modify the existing files if needed.
这篇关于在 Xcode 项目之间共享类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!