migueldeicaza / SkiaKit

Swift Bindings to the Skia 2D graphics Library
Other
135 stars 27 forks source link
graphics2d ios macos skia swift swift-library tvos

SkiaKit

Go to macOS / iOS / tvOS | Go to Linux

SkiaKit is a 2D Graphics Library for use with Swift. It is powered by Google's Skia graphics library, the same library that powers Google Chrome and Android graphics.

You can review the API Documentation

The Swift bindings are intended to be cross-platform, both to Apple platforms, Linux, and new platforms where Skia and Swift run.

This work uses extensive code from Microsoft's SkiaSharp bindings authored by Matthew Leibowitz and dozens of contributors. SkiaSharp just happens to have a very advanced set of bridge APIs to the underlying Skia engine that does not existing in the upstream Google Skia project.

Getting this to work

Apple

Supports:

Not currently supported:

Recommended usage

You can add SkiaKit to your project by putting this dependency in your Package.swift:

.package(url: "https://github.com/migueldeicaza/SkiaKit.git", from: "1.0.0")

Using manually

If using manually, you'll need to download and assemble the SkiaSharp.xcframework required.

This must be ran on macOS with the Command Line Tools for XCode installed.

git clone https://github.com/migueldeicaza/SkiaKit.git
cd SkiaKit
make download-payload

Linux

SkiaKit is platform agnostic and makes a best-effort support for Linux. An .so for the SkiaSharp library is included and supports the following Linux distributions.

The libSkiaSharp.so file will need to be distributed alongside your project.

Recommended usage

You can add SkiaKit to your project by putting this dependency in your Package.swift:

.package(url: "https://github.com/migueldeicaza/SkiaKit.git", .branch("generated"))

Using manually

If using manually, you'll need to provide libSkiaSharp.so in the root of the SkiaKit folder. For certain Linux distros, a convenience script is provided.

This script requires curl and unzip.

git clone https://github.com/migueldeicaza/SkiaKit.git
cd SkiaKit
make download-payload-linux