How khacchan/swift-mvp-module works
Project type and purpose
• This is not a running application but an Xcode project‐template package (Module MVP.xctemplate) plus a small installer script (install.swift).
File structure
• Top-level:
• Module MVP.xctemplate/… — the actual Xcode template folder, containing TemplateInfo.plist and placeholder Swift/XIB files.
• install.swift — a Swift script that installs the template into Xcode’s Templates directory.
• README.md — instructions and documentation.
• No “src” or “backend” directories here: the “system” is the combination of the installer, the template files, and Xcode as the host environment.
README for insights
• It clarifies that the template generates a new “Login module” with Presenter, ViewController, and XIB.
a. Main components:
1. User (developer)
2. install.swift (Installer Script)
3. File System: Xcode Templates folder
4. Module MVP.xctemplate (Template Package)
5. Xcode IDE (Template Engine)
6. Generated Output:
– ___FILEBASENAME___Presenter.swift
– ___FILEBASENAME___ViewController.swift
– ___FILEBASENAME___ViewController.xib
b. Relationships / interactions:
• The developer runs install.swift → the script writes Module MVP.xctemplate into Xcode’s Templates directory.
• In Xcode, the user invokes “New File… → Module MVP” → Xcode’s template engine reads TemplateInfo.plist and placeholders.
• Xcode generates the three files in the user’s project.
c. Architectural patterns & principles:
• Plugin pattern: the template and installer act as a plugin to Xcode.
• Code-generation: placeholders (___FILEBASENAME___) are replaced at creation time.
• MVP pattern: the files produced enforce a separation between ViewController (View) and Presenter.
d. Key technologies/frameworks:
• Swift 5 (for both template code and installer script)
• Xcode Template format (TemplateInfo.plist, .xctemplate folder)
• macOS filesystem paths under Xcode.app/Contents/…/Templates/
5. Inside Xcode IDE, show code-generation process: read TemplateInfo.plist + placeholders → output files under Developer’s Project → Presenter.swift, ViewController.swift, ViewController.xib.