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?
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.
Original answer: By default projects are saved in User/Documents/xCode.
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.
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:
http://akosma.com/2009/07/28/code-organization-in-xcode-projects/
https://github.com/futurice/ios-good-practices/issues/28
http://www.slideshare.net/MassimoOliviero/architecting-ios-project
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With