Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode project files folders structure for Swift & MVVM Architecture [closed]

I am starting a new project today from scratch using Swift and MVVM architecture. I would like to setup the files & folders structure for the best practice I can for easy and understandable navigation and usage.

Most tutorials suggest:

├─ Models
├─ Views
├─ ViewModels
├─ Stores
├─ Helpers

But I find it very lacking as I don't really know what would be the best practice to manage the ViewModels folder.

Any good suggestions from real world super maintainable projects?

Thanks a lot! :)

like image 395
Erez Hod Avatar asked Apr 18 '18 07:04

Erez Hod


People also ask

How do I add a file to a project in Xcode?

To show only files with a changed source-control status, click the Source Control icon. Xcode provides templates for the common types of files you might want to add to your project, such as Swift files or playgrounds. In the Project navigator, select the folder or group where you want to add a file and perform one of the following actions:

What does Xcode do with the files in a folder?

If a group is associated with a folder, Xcode performs all rename, delete, move, and copy operations on the folder in the file system. For projects under source control, Xcode uses the source-control system to perform the operations and track the changes.

How to find the subfolder of a project in Xcode?

After you create the Xcode project ( use Single View App template ), you will find there is a subfolder in the project navigator, the subfolder name is the same as the project name.

What is a group in Xcode?

A group is a collection of resources in your project. By default, Xcode maps each group to a folder in your project directory, but you can also create groups without an underlying file-system folder. You might use groups without folders if you want to manage files in your project without changing the underlying organization of the files on disk.


1 Answers

According to uncle Bob's Clean Architecture pattern, you may divide your code in 3 Layers :

  • Presentation : All Code which is Framework ( Cocoa here ) dependant. So Put your Views, ViewModels, Vierwcontrollers, etc.

  • Data : All the code interacting with repositories ( Like Network Calls, DB calls, User Defaults, etc )

  • Domain : All your Models

like image 191
CZ54 Avatar answered Sep 28 '22 09:09

CZ54