├── .gitattributes ├── .gitignore ├── LICENSE ├── MVVM.xctemplate ├── MVVM │ ├── Model │ │ └── ___FILEBASENAME___Model.swift │ ├── View │ │ └── ___FILEBASENAME___ViewController.swift │ └── ViewModel │ │ └── ___FILEBASENAME___ViewModel.swift ├── RxService │ └── Services │ │ ├── APIRouter.swift │ │ └── APIServices.swift ├── TemplateIcon.png ├── TemplateIcon@2x.png └── TemplateInfo.plist └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.swift linguist-detectable=true 2 | *.rb linguist-language=Swift 3 | 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 MindInventory 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MVVM.xctemplate/MVVM/Model/___FILEBASENAME___Model.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILEHEADER___ 3 | // 4 | import Foundation 5 | 6 | import Foundation 7 | struct ___VARIABLE_productName:identifier___Model : Codable { 8 | 9 | 10 | enum CodingKeys: String, CodingKey { 11 | 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /MVVM.xctemplate/MVVM/View/___FILEBASENAME___ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILEHEADER___ 3 | // 4 | import UIKit 5 | import RxCocoa 6 | import RxSwift 7 | 8 | class ___VARIABLE_productName:identifier___ViewController: UIViewController { 9 | 10 | var disposeBag = DisposeBag() 11 | 12 | // Add here outlets 13 | 14 | // Add here your view model 15 | lazy var viewModel: ___VARIABLE_productName:identifier___ViewModel = { 16 | return ___VARIABLE_productName:identifier___ViewModel() 17 | }() 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | setupUI() 23 | initViewModel() 24 | } 25 | 26 | override func viewWillAppear(_ animated: Bool) { 27 | super.viewWillAppear(animated) 28 | } 29 | 30 | func setupUI() { 31 | // Add here the setup for the UI 32 | } 33 | 34 | func initViewModel() { 35 | // Add here the setup for the ViewModel 36 | 37 | // Setup for closure1 38 | viewModel.closure1 = { [weak self] () in 39 | DispatchQueue.main.async { 40 | // Do something 41 | } 42 | } 43 | 44 | // Setup for closure2 45 | viewModel.closure2 = { [weak self] () in 46 | DispatchQueue.main.async { 47 | // Do something 48 | } 49 | } 50 | 51 | // Populate ViewModel: 52 | // For example: 53 | // viewModel.fetchData() 54 | } 55 | 56 | // MARK: - Navigation 57 | 58 | /* 59 | // In a storyboard-based application, you will often want to do a little preparation before navigation 60 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 61 | // Get the new view controller using segue.destination. 62 | // Pass the selected object to the new view controller. 63 | } 64 | */ 65 | } 66 | -------------------------------------------------------------------------------- /MVVM.xctemplate/MVVM/ViewModel/___FILEBASENAME___ViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILEHEADER___ 3 | // 4 | import Foundation 5 | import RxSwift 6 | import RxCocoa 7 | 8 | class ___VARIABLE_productName:identifier___ViewModel { 9 | 10 | // MARK: - Closures 11 | 12 | // Through these closures, our view model will execute code while some events will occure 13 | // They will be set up by the view controller 14 | var closure1: (()->())? 15 | var closure2: (()->())? 16 | 17 | //MARK:- Validation 18 | 19 | enum ValidationStatus { 20 | 21 | case initial 22 | case success 23 | case failure(errorMessage: String) 24 | 25 | static func == (lhs: ValidationStatus, rhs: ValidationStatus) -> Bool { 26 | 27 | switch (lhs, rhs) { 28 | case (.initial, .initial): 29 | return true 30 | case (.success, .success): 31 | return true 32 | case (let .failure(message1), let .failure(message2)): 33 | return message1 == message2 34 | default: 35 | return false 36 | } 37 | } 38 | } 39 | 40 | var emailValidationStatus: ValidationStatus = .initial 41 | var passwordValidationStatus: ValidationStatus = .initial 42 | 43 | private let disposeBag: DisposeBag = DisposeBag() 44 | 45 | // MARK:- Initialize 46 | 47 | init() { 48 | self.observeUserInput() 49 | } 50 | 51 | func observeUserInput() { 52 | 53 | } 54 | // MARK: - Constructor 55 | 56 | // Add here a custom constructor 57 | 58 | // MARK: - Fetching functions 59 | 60 | func fetchData() { 61 | self.isLoading = true 62 | 63 | // Do something 64 | 65 | //When done: 66 | self.isLoading = false 67 | } 68 | 69 | //MARK:- Moya Sample 70 | /* func loginApi(completion: @escaping (Bool) -> ()) { 71 | 72 | Constants.windowRoot?.view.activityStartAnimating(activityColor: .white, backgroundColor: UIColor.black.withAlphaComponent(0.5)) 73 | 74 | APIServices.shared.authenticateUserAPI( 75 | .loginAPI(LoginModel(email: email.value, 76 | password: password.value))) 77 | .subscribe { (event) in 78 | Constants.windowRoot?.view.activityStopAnimating() 79 | switch event { 80 | case .next(let response): 81 | print(event.element!) 82 | 83 | if response.meta?.code == 1 { 84 | 85 | Constants.windowRoot?.showToast(message: Constants.successLogin, complete: { 86 | completion(true) 87 | }) 88 | } 89 | else { 90 | Constants.windowRoot?.presentAlertViewWithOneButton(alertTitle: "Failed", alertMessage: response.meta?.message, btnOneTitle: "Ok", btnOneTapped: { (action) in 91 | completion(false) 92 | }) 93 | } 94 | case .error(let error): 95 | print("error") 96 | Constants.windowRoot?.presentAlertViewWithOneButton(alertTitle: "Failed", alertMessage: error.localizedDescription, btnOneTitle: "Ok", btnOneTapped: { (action) in 97 | completion(false) 98 | }) 99 | case .completed: 100 | print("completed") 101 | completion(false) 102 | } 103 | }.disposed(by: disposeBag) 104 | }*/ 105 | } 106 | -------------------------------------------------------------------------------- /MVVM.xctemplate/RxService/Services/APIRouter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILEHEADER___ 3 | // 4 | import Foundation 5 | import Moya 6 | 7 | enum APIRouter { 8 | case loginAPI 9 | } 10 | extension APIRouter: TargetType { 11 | var baseURL: URL { 12 | switch self { 13 | case .loginAPI: 14 | return URL(string: "Add base url here.....")! 15 | } 16 | } 17 | 18 | var method: Moya.Method { 19 | switch self { 20 | case .loginAPI: 21 | return .post 22 | } 23 | } 24 | 25 | var sampleData: Data { 26 | return Data() 27 | } 28 | 29 | var task: Task { 30 | switch self { 31 | case .loginAPI: 32 | return .requestParameters(parameters: ["email": "", "password": ""], encoding: JSONEncoding.default) 33 | } 34 | } 35 | 36 | var headers: [String : String]? { 37 | return ["Content-type": "application/json"] 38 | } 39 | 40 | var path: String { 41 | switch self { 42 | case .loginAPI: 43 | return "/login" 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /MVVM.xctemplate/RxService/Services/APIServices.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ___FILEHEADER___ 3 | // 4 | import Foundation 5 | import RxSwift 6 | import RxCocoa 7 | import Moya 8 | 9 | 10 | protocol APIServiceProtocol { 11 | func authenticateUserLogin(_ asyncAPIRouter: APIRouter) -> Observable 12 | } 13 | 14 | fileprivate let asyncServiceprovider = MoyaProvider() 15 | 16 | final class APIServices: APIServiceProtocol { 17 | 18 | private let disposebag = DisposeBag() 19 | private init() {} 20 | static let shared = APIServices() 21 | 22 | //MARK:- Sample API Call 23 | func authenticateUserAPI(_ asyncAPIRouter: APIRouter) -> Observable { 24 | 25 | return Observable.create { (observer) -> Disposable in 26 | 27 | let _ = asyncServiceprovider.rx.request(asyncAPIRouter).asObservable().subscribe { (response) in 28 | switch response { 29 | 30 | case .next(let response): 31 | do { 32 | let responseModel = try JSONDecoder().decode(APIResponse.self, from: response.data) 33 | observer.onNext(responseModel) 34 | observer.onCompleted() 35 | 36 | } catch let exceptionMsg { 37 | observer.onError(exceptionMsg) 38 | } 39 | 40 | case .error(let errorMsg): 41 | observer.onError(errorMsg) 42 | 43 | case .completed: 44 | observer.onCompleted() 45 | } 46 | 47 | }.disposed(by: self.disposebag) 48 | 49 | return Disposables.create() 50 | } 51 | } 52 | 53 | 54 | } 55 | 56 | struct APIResponse : Codable { 57 | 58 | } 59 | -------------------------------------------------------------------------------- /MVVM.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/XcodeTemplate/7427ab532172da508744fcbed4d1d90c85ccf8bc/MVVM.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /MVVM.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mindinventory/XcodeTemplate/7427ab532172da508744fcbed4d1d90c85ccf8bc/MVVM.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /MVVM.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Kind 6 | Xcode.IDEKit.TextSubstitutionFileTemplateKind 7 | Platforms 8 | 9 | com.apple.platform.iphoneos 10 | com.apple.platform.macosx 11 | 12 | SortOrder 13 | 1 14 | Options 15 | 16 | 17 | Identifier 18 | productName 19 | Required 20 | 21 | Name 22 | Module Name: 23 | Description 24 | The name of the Module 25 | Type 26 | text 27 | Default 28 | Module Name 29 | RequiredOptions 30 | 31 | classType 32 | 33 | MVVM 34 | 35 | 36 | 37 | 38 | Identifier 39 | classType 40 | Required 41 | 42 | Name 43 | Class Type: 44 | Description 45 | The type of classes to create 46 | Type 47 | popup 48 | Default 49 | MVVM 50 | Values 51 | 52 | MVVM 53 | RxService 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Xcode Template 2 | Xcode Template can be two types either file template or Project template. Let's see how the Project template will be configured and work. 3 | Find and read more in detail on [MEDIUM](https://medium.com/mindful-engineering/create-custom-xcode-templates-908fdd14fbd8) 4 | 5 | # Project Template 6 | A project template is nothing but a group of reusable files which will be created automatically when you select and configure your template as a project. 7 | 8 | # Set Up to Install the Project Template 9 | Go to the path ~/Library/Developer/Xcode/ where you can create your own project template folder with the extension **.xctemplate** . 10 | Add require Image files which will be useful while showing project template in Xcode panel and modified Info.plist file. 11 | Find more on this over [MEDIUM](https://medium.com/mindful-engineering/create-custom-xcode-templates-908fdd14fbd8) 12 | 13 | Once you add the folder with images and info.plist file it will look like 14 | 15 | [![Project-Template.png](https://i.postimg.cc/TwBw91dD/Project-Template.png)](https://postimg.cc/47bs4Jhf) 16 | 17 | Now add the required folder and files to add to the project template and your folder for the Project template will be structured like below 18 | 19 | [![1-CPs-GPeb-B6s-OO9-U3-Dt-GF33w.png](https://i.postimg.cc/PxjV8zZp/1-CPs-GPeb-B6s-OO9-U3-Dt-GF33w.png)](https://postimg.cc/ns3Gym3p) 20 | 21 | Once you add this template in your Xcode from the pannel the final project will be created with the following files and folder 22 | 23 | [![1-I-a0qs-J550fy-No-ZHc6r0vw.png](https://i.postimg.cc/9FY9WPXg/1-I-a0qs-J550fy-No-ZHc6r0vw.png)](https://postimg.cc/Yhj0RWWQ) 24 | 25 | ## Contributing 26 | 27 | Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. 28 | Please make sure to update tests as appropriate. 29 | 30 | ## License 31 | 32 | Xcode Template is [MIT-licensed](/LICENSE). 33 | --------------------------------------------------------------------------------