Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's an easy way to manage source files that are shared among different Xcode projects?

I'm diving into iOS development and I plan to build a few basic apps that make use of my own reusable code. As I update the files that contain my reusable code, I'd like those updates to be reflected in all the Xcode projects that use them. What are some ways I can do this?

Thanks in advance for your help!

like image 745
BeachRunnerFred Avatar asked Jan 28 '26 13:01

BeachRunnerFred


1 Answers

There are a few ways you can do it.

If your "reusable code" is separated into libraries, you could package it up as individual projects (that compile to static libraries) and then link them into your main project (that compiles into an executable). A bit tricky, but it's the "proper" way. (Not as flexible or easy as Visual Studio's solution/project paradigm, but that's a rant for another day.)

You could also just drag-and-drop a directory containing the source files into the Project window directly, either using "Create Folder References" or "Recursively create groups". (Either way, you don't want to use the "Copy items" checkbox at the top if you want only one copy of the source files.)

I've done all three.

You may want to start with the latter -- group your "reusable code" into a folder somewhere (so there's only one copy) and then drag-and-drop that folder into your project using "Recursively create groups". One warning: if you do that in multiple projects, and sometime later you want to remove it from the project, don't use the option to send it to the trash, or your other projects could get messed up.

like image 177
Shaggy Frog Avatar answered Jan 30 '26 01:01

Shaggy Frog