Search code examples
cocoacode-organization

How to structure a Cocoa project


When I write in Python I can structure my source code as several files and folders, effectively creating the modules. I then can import a module, a file can have several classes, and so on.

How to structure a project written in Cocoa? Can a .m file implement multiple classes? Is there a notion of a "module"? What exactly is a "framework" for? Is it possible to create a framework of mine? How do I "import" it into another project? And what happens at compilation time, does the compiler embed frameworks into one giant executable or are they living next to the executable, merely being copied into the bundle folder?


Solution

  • It really sounds like you should start with some Apple resources like Your First Mac App and What are Frameworks?

    To answer your questions specifically - a .m can contain multiple class implementations; a Framework is a bundle of shared resources; a Framework is a library for reuse; you can create your own Frameworks; in a typical Mac application bundle the frameworks are copied into the application bundle.

    There are also a bunch of good resources concerning the structure and design of Cocoa applications - I particularly like this Cocoa With Love post.