Search code examples
xcodebuildtargetworkspace

How should I use a library of classes I made in Xcode for an iPhone application?


I wrote a set of objective c classes, which I now plan on using in a project of mine. My old way would be to copy-paste them in, but that's sloppy, especially now that Xcode has got me using unit tests and code repositories.

I'm thinking what I need is maybe to #include the library from its current location by path maybe, or add a target or a workspace or something, I just don't understand Xcode well enough to know how all this works. The outcome I'd like is for my existing classes to stay synchronized with the project they are in, and not be copied separately, so I can open that project, make changes, build and unit test, and otherwise not alter that library.

Can someone point my in the right direction here? Sorry if this is confusing, I don't know enough about it to really know what I'm asking.


Solution

  • you would create a static library for the shared sources (which may have its own repo), then link that to your app. it's best to configure the library in an external project, configure the static library target as a dependency to the app. naturally, you'll have to add the static lib's source directory to your app target's header search paths.