This Python script builds a Swift Package Manager artifact bundle for pre-compiled Skia binaries.
- Downloads Skia binaries from GitHub releases for multiple platforms:
- macOS Universal (x86_64 + arm64)
- Linux x64
- Linux ARM64
- Windows x64
- Extracts and organizes binaries and headers
- Creates a complete artifact bundle with proper Swift Package Manager structure
- Includes all Skia headers (339+ header files)
- Generates umbrella header for easy integration
# Build artifact bundle with default Skia version (m126-6bfb13368b)
python3 build_skia_bundle.py
# Specify a different Skia version
python3 build_skia_bundle.py --version m125-5bfb13368a
# Specify custom output directory
python3 build_skia_bundle.py --output custom_skia.artifactbundle
# Create a ZIP file for easy distribution
python3 build_skia_bundle.py --zip
# Combine options
python3 build_skia_bundle.py --version m127-7bfb13368c --output custom.artifactbundle --zip
# Get help
python3 build_skia_bundle.py --help
--version
: Skia version to download (default:m126-6bfb13368b
)--output
: Output directory for the artifact bundle (default:skia.artifactbundle
)--zip
: Create a ZIP file of the artifact bundle for easy distribution
The script creates an artifact bundle with the following structure:
skia.artifactbundle/
├── info.json # Swift Package Manager metadata
├── module.modulemap # Module map for Swift integration
├── include/ # All Skia headers
│ ├── skia.h # Umbrella header
│ ├── core/ # Core Skia headers
│ ├── gpu/ # GPU-related headers
│ ├── effects/ # Effects and filters
│ └── ... # Other header directories
├── macos-universal/
│ └── libskia.a # Universal binary for macOS
├── linux-x64/
│ └── libskia.a # Linux x86_64 binary
├── linux-aarch64/
│ └── libskia.a # Linux ARM64 binary
└── windows-x64/
└── skia.lib # Windows x64 binary
Add the artifact bundle to your Swift package by including it in your Package.swift
:
let package = Package(
name: "YourPackage",
products: [
.library(name: "YourLibrary", targets: ["YourTarget"]),
],
targets: [
.target(
name: "YourTarget",
dependencies: ["skia"]
),
.binaryTarget(
name: "skia",
path: "path/to/skia.artifactbundle"
),
]
)
- Python 3.6+
- Internet connection to download Skia binaries
- Sufficient disk space (~500MB for temp files and artifact bundle)
This repository includes a GitHub Actions workflow that automatically builds and releases Skia artifact bundles.
The workflow is triggered by:
- Releases: When you create a GitHub release, it automatically builds the artifact bundle
- Manual Dispatch: You can manually trigger builds with custom Skia versions
- Push to Main: Builds are triggered when the script or workflow files are updated
To create a release with a specific Skia version:
- Go to the "Actions" tab in your GitHub repository
- Select "Build Skia Artifact Bundle" workflow
- Click "Run workflow"
- Specify the Skia version (e.g.,
m127-7bfb13368c
) - Optionally specify a release tag to upload to
- Multi-platform builds: Creates artifact bundles for all supported platforms
- Automatic uploads: ZIP files are uploaded to GitHub releases
- Artifact storage: Build artifacts are stored for 30 days for download
- Detailed release notes: Auto-generated documentation with usage instructions
The script downloads files to a ./temp
directory for inspection. These files are not automatically cleaned up, allowing you to examine the contents if needed.
This script is based on the logic from skiadownload.swift
and follows the artifact bundle format specified in Swift Evolution SE-0482.