简体   繁体   中英

Sharing classes between Xcode projects

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?

Thanks in advance for any help.

我更喜欢为选定的文件创建单独的Git存储库,并将该存储库作为子模块嵌入到两个项目(新旧项目)中

In similar situation I done it using XCode Workspace and Static Library.

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.

I have two options there:

  1. Adding that Static Library project to the new project workspace
  2. Adding the static library (.a) project to the new project

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.

As Midhun and yourself mentioned, the best way to do it us by making a workspace and adding your projects to that.

Your shared code can go into a new project that's basically empty and dragged/linked from there into any projects in your workspace.

Changes made to that code from any project will also update the shared code base, which I think is what your ultimate goal was.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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