A lightweight, productivity-focused VS Code extension to generate and remove Swift InjectionNext boilerplate code in SwiftUI Views with exactly one tap or a keyboard shortcut.
Designed to seamlessly match modular SwiftUI layouts and strict sorting/formatting guidelines (e.g. alphabetical imports, proper block-level indentation).
Features
⚡ One-Tap Generate: Inserts all InjectionNext boilerplate code into your active SwiftUI file instantly.
🗑️ One-Tap Remove: Completely and safely cleans up all Swift InjectionNext boilerplate before you make commits or open Pull Requests.
⌨️ Intuitive Keyboard Shortcuts: No need to lift your hands off the keyboard.
How It Works
The extension parses your active SwiftUI View and intelligently inserts three core elements according to Erafone's strict layout rules:
import Inject
Placed automatically in alphabetical order within your import block.
@ObserveInjection var inject
Placed as the first property inside your main struct View, matching your file's local indentation perfectly (supports 2-space or 4-space layouts).
.enableInjection()
Placed precisely as the very last modifier of your main body property (right before the closing brace).
Usage & Shortcuts
1. Editor Toolbar Icons (One-Tap)
When editing a .swift file, you will find two new icons in the top-right corner of your editor toolbar:
Click ⚡ to Generate Swift Injection.
Click 🗑️ to Remove Swift Injection.
2. Keyboard Shortcuts
Generate:command + option + I
Remove:command + option + K
Installation
1. From VS Code Extension Marketplace (Recommended)
Open VS Code.
Open Extensions view (Cmd+Shift+X on macOS, Ctrl+Shift+X on Windows/Linux).
Search for Swift Injection Generator or Pamungkas.swift-injection-generator.
Click Install.
2. Manual Installation (From Source)
Clone or copy the extension folder.
Run compilation & packaging in the directory:
npm install
npm run compile
npx @vscode/vsce package
Install the generated .vsix file in VS Code:
Go to Extensions (Cmd+Shift+X).
Click the ... menu in the top-right.
Choose Install from VSIX...
Select swift-injection-generator-xxx.vsix.
Requirements
VS Code v1.80.0 or newer.
Swift language package installed for syntax detection.
License
This extension is open-sourced under the MIT License.