{"id":19805673,"url":"https://github.com/remirobert/mvvmbaseproject","last_synced_at":"2025-06-28T02:05:04.518Z","repository":{"id":72988989,"uuid":"57430704","full_name":"remirobert/MVVMBaseProject","owner":"remirobert","description":"Base project to start new app (extremely) quickly, with MVVM architecture. 项目（使用MVVM结构）基于App极速启动","archived":false,"fork":false,"pushed_at":"2016-05-08T10:29:57.000Z","size":44,"stargazers_count":34,"open_issues_count":0,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-01T06:36:58.216Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remirobert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-04-30T06:51:23.000Z","updated_at":"2024-11-07T05:28:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"e8250ad9-d7af-4790-98c9-e76ca7116ff3","html_url":"https://github.com/remirobert/MVVMBaseProject","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/remirobert/MVVMBaseProject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FMVVMBaseProject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FMVVMBaseProject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FMVVMBaseProject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FMVVMBaseProject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remirobert","download_url":"https://codeload.github.com/remirobert/MVVMBaseProject/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FMVVMBaseProject/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262362064,"owners_count":23299122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T09:04:54.240Z","updated_at":"2025-06-28T02:05:04.512Z","avatar_url":"https://github.com/remirobert.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg width=\"444\" alt=\"screen shot 2016-04-30 at 17 52 16\" src=\"https://cloud.githubusercontent.com/assets/3276768/14935221/65cda908-0efc-11e6-993c-6bca57faeb62.png\"\u003e\n\n项目（使用MVVM结构）基于App极速启动\n\nAs is common in every app development cycle, there comes a time when we must start setting up a project. And this is pretty much always the same steps. Setting up folders, architecture, Podfile, etc.\n\nThis is a base project in **Swift**, for **iOS** application. This base project is based on the **MVVM** architeture. It's totally automated thanks to a script, for fast production.\n\n#Installation\n\nTo install this base project, for your new app, just run the script *install.sh*. This will rename the base project with your app name, and install pods. After that, you will be ready to go.\n\n```sh\ngit clone https://github.com/remirobert/MVVMBaseProject.git\ncd MVVMBaseProject\n./install.sh YOUR_APP_NAME\n```\n\n![tty](https://cloud.githubusercontent.com/assets/3276768/14935252/5b072566-0efd-11e6-9842-28ae8d7ace0e.gif)\n\n#Architecture\n\n####📱 production / 🛠 development\n\nThe project has two different targets, **prod** and **dev**. And with the marco **DEV**, you can configure some global variables like the *URL of your server*, etc. Also two different LaunchScreens are provided to avoid confusion when you are developing your app.\n\nThis is how you can setup some variables depending on your developement environement. You can switch easily between two modes with the schemes.\n```Swift\n#if DEV\nlet SERVER_URL = \"http://dev.server.com/api/\"\n#else\nlet SERVER_URL = \"http://prod.server.com/api/\"\n#endif\n```\n\n####MVVM\n\nThe structure of the base project is based on the **MVVM** (*Model-View-ViewModel*) architecture.\n\n![ic564167](https://cloud.githubusercontent.com/assets/3276768/14935286/4cc0b0f2-0efe-11e6-93b0-1e639a3d659a.png)\n\n\nThere are three core components in the MVVM pattern: the model, the view, and the view model. Each serves a distinct and separate role. The following illustration shows the relationships between the three components.\nSo, in the **iOS development** the UIViewController has the UIView, and the controller. Each **UIViewController** has its one **ViewModel**.\n\nTo handle the communication between the **UIViewController** and the **ViewModel**, I use **RxSwift**, to observe the data, and bind it with the **UIView** (*Any Reactive programing framework can be use here. You can event use some delegate pattern*).\n\nThis design pattern will avoid you the **MEGA UIViewController** (thanks god 🙏).\n\n####AppCoordinator\n\nThe idea being that is to move the **UIViewController** initalisation outside the application context by :\n\n - manage the transitions between **UIViewController**, and the way to present them (*present, push, show, etc*)\n - initialise the **ViewModel** for each **UIViewController**\n - handle the data flow between **UIViewController**\n\nAt this point each **UIViewController**, are less or more very generic, and can be reused in an another application very easily.\n\nexample for a *LoginViewController*:\n\n*AppCoordinator.swift*:\n```swift\nprivate func instanceLoginController() {\n  guard let vc = LoginViewController.instanceController(StoryBoards.Login) as? LoginViewController else {\n     return\n  }\n  \n  vc.transitions = LoginTransitions(\n     didLogin: {\n       self.instanceFeedController()\n  })\n  \n  //init ViewModel, can passe some data from other controllers\n  vc.viewModel = LoginViewModel()\n  self.rootController = UINavigationController(rootViewController: vc)\n  vc.start()\n}\n```\n\n*LoginViewController.swift*:\n```swift\nstruct LoginTransitions {\n    var didLogin: (Void -\u003e Void)\n}\n\nclass LoginViewController: UIViewController, Coordinable {\n\n    var transitions: LoginTransitions?\n \n    typealias ViewModel = LoginViewModel\n    var viewModel: ViewModel?\n \n    func didLoginUser() {\n      ...\n  \n      self.transitions?.didLogin()\n    }\n \n    ...\n}\n```\n\nmade in 同济 with ❤️\n\n\nIf you have any suggestion to improve this architecture, or some reckon, please be free to tell me. All the **pull request** are welcome And also don't forget to ⭐️ if you like it 😉.\n\n![ezgif-1103114166](https://cloud.githubusercontent.com/assets/3276768/14935398/e087e6ee-0f02-11e6-9469-16ac856aa2ff.gif)\n\n\n## License\n\n`MVVMBaseProject` is released under an [MIT License][mitLink]. See `LICENSE` for details.\n\n\u003e**Copyright \u0026copy; 2016 Rémi ROBERT.**\n\n*Please provide attribution, it is greatly appreciated.*\n\n[mitLink]:http://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremirobert%2Fmvvmbaseproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremirobert%2Fmvvmbaseproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremirobert%2Fmvvmbaseproject/lists"}