ObjectiveC project organization

246 Views Asked by At

I wonder what is the more appropriate structure for a Objective-C project (a project that have more than ten classes...).

Code source

I put each class declaration and implementation respectively in a .h and .m files. Moreover I organize these files within a tree of folders. I don't want to have all my source files in a single folder. Is it the best approach for such project?

Building

What is the best approach to build Objective-C applications? I see that using makefile is possible but it seems that you need to specify all involved source files... Is it possible to have something to simply configure all source files for the build?

Packaging

What is the way to package the application in order to provide it as a library?

Thanks very much for your help! Thierry

1

There are 1 best solutions below

1
On

Code source

Putting relevant .h and .m files together in a subdirectory is fine. If you want the traditional Unix source layout, then put these subfolders into a directory named src, let your makefile build the library and intermediate object fiels into a filder named bld and put your Makefile in the top level directory, along with a LICENSE, a README and a CHANGELOG file.

Building

Using Makefile syntax, you can let Make build all source files into one library. Google a Makefile tutorial, but I can tell you that you probably want is something like

OBJECTS  = $(patsubst %.o, %.m, $(wildcard Helpers/*.m))
OBJECTS += $(patsubst %.o, %.m, $(wildcard Network/*.m))
OBJECTS += $(patsubst %.o, %.m, $(wildcard External/*.m))

etc.

Packaging

I don't really understand this part of your question. How do you want to release it? You can distribute the source, and put into a tar(.gz or .bz2)ball. Or upload it to GitHub. Or build the source for some platforms, and make a DEB or RPM package out of the builds. It's difficult to tell in general, as every platform has something else (and not very specific) as convention.