Automatically finds and replaces C-style #include with the correct #import in Objective-C files (.m, .mm) that you've changed in your Git repository.
This extension helps maintain code consistency in Objective-C projects by ensuring all header inclusions use the standard @import or #import directive, but it only acts on the files you are currently working on, as detected by git diff.
Features
Git-Aware: Only scans files listed in your Git working tree changes or staged changes. No unnecessary processing of your entire project.
Smart Repository Detection: If you have multiple projects in your workspace, it intelligently targets the repository of your currently active file. If no file is open, it will scan all repositories.
One-Command Operation: A single command fixes all relevant files.
Safe Replacements: Only replaces #include directives found in added lines of your diff, preventing accidental changes to untouched code.
File-Specific: Works exclusively on .m and .mm files.
How to Use
Make changes to one or more .m or .mm files in your Git-managed project.
Save the files. You will see them appear in VS Code's Source Control panel.
Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on Mac).
Type or select "Fix #include to #import in Git Diff".
The extension will instantly apply the changes to all modified lines across all relevant files.
How It Works
The extension leverages VS Code's built-in Git API to:
Identify the current Git repository based on the active text editor.
Request a diff of all modified .m and .mm files against the HEAD commit.
Parse the diff to find lines that were added (+).
If an added line contains a #include, it creates a workspace edit to replace it with #import.
Finally, it applies all edits in a single, atomic operation.