Swiftpack.co - alex566/Match3Kit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by alex566.
alex566/Match3Kit 0.7
Library for simple Match3 games.
⭐️ 39
🕓 13 weeks ago
iOS macOS tvOS
.package(url: "https://github.com/alex566/Match3Kit.git", from: "0.7")


Library for simple Match3 games. It can work with a solid grid of figures and spill them only in columns.

Forest walk


Create the enum for all kinds of figures:

typealias MyGrid = Grid<Shape>
typealias MyController = Controller<Shape, Generator<Shape>, Matcher<Shape>>

enum Shapes: String, GridFilling {
    case square
    case circle
    case triangle

    var pattern: Pattern {
        Pattern(indices: [])

Create a grid controller with configurations:

let controller = MyController(
    size: Size(columns: 6, rows: 6),
    basic: [.square, .circle, .triangle],
    bonuse: [],
    obstacles: []

Create UI based on the grid that the controller generated:

for index in allIndices {
    let cell = controller.grid.cell(at: index)
    setupUI(for: cell, at: index)

Swap figures after the user interaction:

func swap(source: Index, target: Index) {
    if controller.canSwapCell(at: source, with: target) {
        swapUI(source, target)
        if controller.shouldSwapCell(at: source, with: target) {
            let indices = controller.swapAndMatchCell(at: source, with: target)
            let match = controller.match(indices: indices, swapIndices: [source, target], refill: .spill)
        } else {
            swapUI(source, target)

Used in:

Forest walk

Forest walk


  • Add more examples with bonuses
  • Add a demo project


Stars: 39
Last commit: 3 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