A Parser for Portable Game Notation including Portable Draughts Notation


Build Status Version Platform Carthage compatible License

PGNParser is designed to parse Portable Game Notation files describing Chess and Draughts moves into simple Swift structures.

Currently, only the draughts game strings have been implemented. Pull requests are welcome for further features.

Parsing can be enacted by simply making a single 'parse' call on the draughts move struct.

A result type will be returned which will contain the resulting move array or details of any failure.

A failure contains an enumeration describing the reason for the failure and usually the token which failed.

The following PGN string will parse to a DraughtsMove structure containing a black and a white move.

let sinlgeMoveTwoPlayers = "1. 9-14 23-18"

switch DraughtsMove.parse(fromPortableGameNotation: sinlgeMoveTwoPlayers) {
case .success(let moves, let tail):
// moves - a list of the above moves and any comments parsed into DraughtsMove structs.
case .failure(let reason):



There are 2 external requirements for this project. Both by Tigerpixel, the same authors.

Currier - A helper for currying functions and initializers which is used with the project.

ParserCombinator - A General parser combinator which is extended to build PGNParser.

  • iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 11+
  • Swift 5.1+


Swift Package Manager

The Swift Package Manager is the official tool for managing the distribution of Swift code. It is currently available for all Apple platforms. It can also be used with Linux but this project does not fully support Linux at this point in time.

If you use it to manage your dependencies, simply add PGNParser to the dependencies value of your Package.swift file.

dependencies: [
.package(url: "", from: "0.4.0"),

The Swift Package Manager can resolve sub-dependencies.


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

pod "PGNParser"


If you use Carthage to manage your dependencies, simply add the following lines to your Cartfile:

github "tigerpixel/PGNParser"
github "tigerpixel/Currier"
github "tigerpixel/ParserCombinator"

If you use Carthage to build your dependencies, make sure you have added PGNParser.framework, Currier.framework and ParserCombinator.framework to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.

Git Submodule

  1. Add the PGNParser repository as a submodule of your application’s repository.
  2. Run git submodule update --init --recursive from within the PGNParser folder.
  3. Drag and drop PGNParser.xcodeproj into your application’s Xcode project or workspace.
  4. On the “General” tab of your application target’s settings, add PGNParser.framework. to the “Embedded Binaries” section.
  5. If your application target does not contain Swift code at all, you should also set the EMBEDDED_CONTENT_CONTAINS_SWIFT build setting to “Yes”.

MIT License

PGNParser is available under the MIT license. Details can be found within the LICENSE file.


  • Swift Tools 5.1.0
View More Packages from this Author


Last updated: Fri May 26 2023 17:58:54 GMT-0500 (GMT-05:00)