views:

72

answers:

4

Hello. 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!

+4  A: 

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.

Shaggy Frog
wonderful, I'll give the ladder option a try! thanks!
BeachRunnerJoe
A: 

One solution I've thought of is to build a static library project, but only use it just to test compile the reusable code in that library. Then symlink the reusable source code subdirectory of that library project into all other projects that use that code. That way all the source code is available in any project, and any changes I make in the reusable code will be reflected everywhere else immediately (no copy step). And of course, use a good source code revision control methodology on that subdirectory, so that I can version it, compare changes, revert, etc.

hotpaw2