I have to discover a approach to show a chess UI in my iOS app.
I needn’t assist the precise sport course of (neither between two people, nor vs AI). I want the UI to have the ability to replay the sport that already occurred, load FEN/pgn, transfer ahead/backward alongside the sport historical past, possibly assist sport evaluation (as in make strikes branching off the primary sport course).
Upon checking among the current options, I’ve tried to make work 2 of them:
-
Amongst Swift-based libs I’ve discovered swift-chess:
https://github.com/dpedley/swift-chess
appears to be like fairly good, however the issue is the items aren’t draggable, and I’m not certain it helps the performance I want. -
One other one appears to be like even higher, but it surely’s a js part:
chessboardjs from https://chessboardjs.com
I attempted displaying it inside WKWebView like this:
let html = """
<div id="board1" model="width: 400px"></div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2"
crossorigin="nameless"></script>
<script src="https://unpkg.com/@chrisoakman/chessboardjs@1.0.0/dist/chessboard-1.0.0.min.js"
integrity="sha384-8Vi8VHwn3vjQ9eUHUxex3JSN/NFqUg3QbPyX8kWyb93+8AC/pPWTzj+nHtbC5bxD"
crossorigin="nameless"></script>
"""
let webView = WKWebView()
webView.loadHTMLString(html, baseURL: nil)
webView.evaluateJavaScript("var board1 = Chessboard('board1', 'begin')") { end result, error in
}
However this leads to the error complaining that it would not know what Chessboard
is.
Please, advise how I may clear up the mixing downside.
Alternatively, are there possibly swift/Goal-C written libraries that might clear up my function?
Thanks prematurely for any assist.