Extend xcdiff to become a git difftool for Xcode Projects
- Dominant language
- Swift
- Stars
- 962
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
`xcdiff` can diff two standalone Xcode Projects. An interesting use case that can be extended from this is using `xcdiff` as a git difftool to allow comparing an Xcode project against itself within source control.
**Describe the solution you'd like**
There a few bits needed to make this work:
- Support diffing `.pbxproj` files directly (not just `.xcodeproj`)
- Difftools are passed two files to diff, in for Xcode project files this will be the underlying `.pbxproj` files
- Add a new renderer that uses terms like "Removed" / "Added" rather than "Only in first" / "Only in second"
- Optionally this renderer could use terminal colors, green text for added items, red for removed, yellow for modified
- Update documentation with instructions on how to add `xcdiff` as a diff tool
e.g.
```sh
git config --local difftool.xcdiff.cmd 'xcdiff -p1 $(dirname "$LOCAL") -p2 $(dirname "$REMOTE") -d -v
```
```sh
git diff --tool xcdiff
```
_There might be a way to make git automatically select a diff tool for certain file extensions which we could leverage as well (needs more research)._
**Describe alternatives you've considered**
Instead of extending `xcdiff` itself, we can leverage a bash script to marshal the `.pbxproj` files to the desired format that enables `xcdiff` to read it.
e.g.
```sh
#!/bin/bash
tmp_dir_1="$(mktemp -d -t xcdif)"
cp "$1" $tmp_dir_1/project.pbxproj
tmp_dir_2="$(mktemp -d -t xcdiff)"
cp "$2" $tmp_dir_2/project.pbxproj
xcdiff -p1 "$tmp_dir_1" -p2 "$tmp_dir_2" -d -v
```
Another alternative could be to add an additional executable target `xcgitdiff` that manages some of this under the hood and uses a special renderer that is more suitable for this use case.
**Additional context**
I have a [prototype](https://github.com/kwridan/xcdiff/commits/feature/gitdiff) of a custom renderer that replaces terms:
- "Only in first" > "Removed"
- "Only in second" > "Added"
- "Value mismatch" > "Modified" or "Changed"
`xcdiff --format git`
Not sure how useful this feature is, but posting here to collect ideas and see if there's interest to pursue this further.
Contributor guide
Research direction
Start by reviewing xcdiff's existing project-input and renderer paths, then compare them with the feature/gitdiff prototype mentioned in the issue. Check how direct .pbxproj inputs and the proposed git difftool commands should flow through the tool. Done means direct project-file diffing, a suitable added/removed/modified renderer, and documented setup instructions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, swift
- Domain
- cli, documentation, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100