Swiftpack.co - wmcginty/Diffing as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by wmcginty.
wmcginty/Diffing 0.5.0
A simple implementation of Heckel's diffing algorithm in Swift
⭐️ 0
🕓 4 weeks ago
iOS macOS tvOS
.package(url: "https://github.com/wmcginty/Diffing.git", from: "0.5.0")


CI Status Version Platform

Diffing is a small framework that is desgined to make identifying the differences, or edits, between any two collections as quick and simple as possible. An implementation of Paul Heckel's algorithm, Diffing uses a series of five passes over two collections to identify the differences between a given source and destination collection and output them in a way that is both easy to understand, and easy to apply to UI elements like UITableview and UICollectionView.

For example, given the following two collections:

let old = [1, 2, 3, 4, 5]
let new = [1, 2, 3, 4, 5, 6]

A simple extension on Collection can be invoked to determine the differences:

let difference = old.difference(to: new)
difference.sortedChanges // [.insert(value: 6, index: 5)]

In addition, the set of changes in difference can also be applied to any arbitrary collection. Applying this set of changes to old in this case, will always produce new.

let equals = old.applying(difference: difference) == new // true


Diffing is heavily inspired by similar frameworks like the incredible IGListKit. The original algorithm published by Paul Heckel is available here.


Requires iOS 10.0, tvOS 10.0, macOS 10.12



Diffing is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Diffing'


Add the following to your Cartfile:

github "wmcginty/Diffing"

Run carthage update and follow the steps as described in Carthage's README.

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/wmcginty/Diffing.git", from: "0.4.0")


Stars: 0
Last commit: 4 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics