1

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.

Darren Findlay
  • 2,533
  • 2
  • 29
  • 46

3 Answers3

3

I prefer to create separate Git repository for selected files, and embed this repository as submodule in both projects (old and new one)

Vitalii Gozhenko
  • 9,220
  • 2
  • 48
  • 66
2

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.

Midhun MP
  • 103,496
  • 31
  • 153
  • 200
0

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.

Travis M.
  • 10,930
  • 1
  • 56
  • 72