Swiftpack.co - Package - dpedley/swift-chess
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.


This package provides UI components and game logic for standard chess play. The code presents a unified pattern for the game interactions using Combine and SwiftUI.

You can find an example Xcode project in the "PlayChess" folder.

This app is also available in the App Store if you'd like to try it.

Getting Started

The main starting place for using swift-chess is the ChessStore

It houses a chess game, its board, and players. It provides the game and environment interface via a reducer pattern.

Here's an example of creating a ChessStore that would allow two people to play.

let white = Chess.HumanPlayer(side: .white)
let black = Chess.HumanPlayer(side: . black)
let game = Chess.Game(white, against: black)
let store = ChessStore(game: game)

You might then use the store as the environment variable for a BoardView.

Going Further

There is a lot to discover, you will find previews in the code, this can be helpful to get a visual guide.

Here's XCode showing the preview of SquareTargeted.swift.

When a user taps a square we show the possible moves on the board.


Find a bug? Need help w/ the docs?

Please use the issues here, or open a pull request.

If you have a question about the App Store version, you can find more info at chess.toys


Stars: 1



Release 1.0.8 - 2021-01-07T04:03:16

This is the version for the initial app store release.

Initial Beta Package - 2020-12-09T17:14:12

The package is in a place that is best tested via another application. So we'll publish a beta release and move forward.