Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for an Xcode project groups structure?

Tags:

In tutorials and examples that provide code samples, sometimes I see that project files in the Xcode's Project navigator are arranged by groups following the MVC pattern ("Views", "Controllers", "Model"), and other times they are organized into groups by functionality ("Login", "Checklist", for instance).

Concerning iOS, is there any Apple's convention/recommendation for this? Which should be the best practice?

like image 930
AppsDev Avatar asked Oct 09 '16 16:10

AppsDev


People also ask

How do I organize files in Xcode?

You can drag and drop folders into Xcode. Drag and drop your Source folder underneath your app project. Click yes to the standard options. You want Xcode to copy your files.

Where should I save my Xcode projects?

Original answer: By default projects are saved in User/Documents/xCode.

What is Xcode project format?

The Xcode project file is an old-style plist (Next style) based on braces to delimit the hierarchy. The file begins with an explicit encoding information, usually the UTF-8 one. This means that the file must not bear a BOM (Byte Ordering Mark) at its start or the parsing will fail.


1 Answers

Developers organise their groups, code, and files many ways. But I use something like the following:

  • CoreData: Contains DataModel and Entity Classes.

  • Extension: Contain One class(default apple class extensions+project class extensions.)

  • Helper: Contain Third Party classes/Frameworks (eg. SWRevealController) + Bridging classes (eg. Obj C class in Swift based project)

  • Model: Make a singleton class (eg.AppModel - NSArray,NSDictionary, String etc.) for saving data. The Web Service Response parsing and storing data is also done here.

  • Services: Contain Web Service processes (eg. Login Verification, HTTP Request/Response)

  • View: Contain storyboard, LaunchScreen.XIB and View Classes. Make a sub folder Cells - contain UITableViewCell, UICollectionViewCell etc.

  • Controller: Contain Logic or Code related to UIElements (eg. UIButton’s reference+ clicked action) It could be replaced by ViewModel if MVVM is employed.

This structure is from another Stack Overflow post.

These may also help you:

  1. http://akosma.com/2009/07/28/code-organization-in-xcode-projects/

  2. https://github.com/futurice/ios-good-practices/issues/28

  3. http://www.slideshare.net/MassimoOliviero/architecting-ios-project

like image 196
Jamshed Alam Avatar answered Nov 26 '22 06:11

Jamshed Alam