Add ChessgroundAssets Swift package#92
Merged
veloce merged 3 commits intoApr 13, 2026
Merged
Conversation
Collaborator
|
Looks good! Thanks you very much. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Swift Package Manager package that exposes the same board textures, piece images, and theme colour data that the Dart side already ships — so iOS/macOS native targets (e.g. WidgetKit extensions) can consume them without a copy script.
What's included
Package.swift— SPM manifest at the repo root. Declares a singleChessgroundAssetslibrary targeting iOS 16+ / macOS 13+.swift/Sources/ChessgroundAssets/ChessgroundAssets.swift— exposesChessgroundAssets.bundlefor loading assets:Image("board_wood2", bundle: ChessgroundAssets.bundle)ChessboardTheme.swift— publicChessboardThemestruct that maps Dart theme names to light/dark square colours, last-move highlight colour, board image name, and piece set. Mirrors theChessboardColorSchemeconstants inboard_color_scheme.dart.Assets.xcassets/— generated Xcode asset catalog: 21 board texture imagesets and 468 piece imagesets (39 sets × 12 pieces, each with 1x/2x/3x).scripts/gen-swift-xcassets.sh— regenerates the asset catalog fromassets/whenever boards or piece sets change. No Flutter tooling needed — reads directly from the repo. Run it and commit the result before cutting a new release tag..gitignore— added.build/and.swiftpm/(SPM artifacts generated at the repo root).README.md— new "Swift Package (iOS/macOS)" section documenting the dependency, asset naming conventions,ChessboardThemeAPI, and how to maintain the xcassets.Motivation
The lichess mobile app's WidgetKit extension previously copied assets out of the pub cache via a shell script, creating a fragile coupling between the iOS build and Flutter tooling. With this package, the extension declares a normal SPM dependency on this repo — assets are versioned alongside the Dart package and consumers just update the SPM version tag when chessground is upgraded.
Asset naming
board_{name}board_blueMarble,board_wood3piece_{set}_{color}{kind}piece_staunty_wK,piece_california_bQnamematches theChessboardColorSchemeDart constant.setis the camelCasePieceSetenum.namevalue. Themonopiece set is excluded (non-standard file layout).