Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Releases: thorvg/thorvg.swift

v0.1.2

10 Dec 04:46

Choose a tag to compare

[0.1.2] - 2025-12-10

Fixed

  • Submodule Configuration Update - Changed submodule URL from SSH to HTTPS to help with local developer builds

v0.1.1

20 Nov 01:49

Choose a tag to compare

[0.1.1] - 2025-11-20

Fixed

  • Release Process: Corrected v0.1.0 tag to properly include pre-built XCFramework binaries
  • This is the actual first stable release with all assets

Note

  • v0.1.0 was published without the XCFramework due to a release process issue
  • All users should use v0.1.1 or later for access to pre-built binaries

v0.1.0

20 Nov 01:50

Choose a tag to compare

We're excited to announce the initial public release of ThorVGSwift - a lightweight Swift wrapper around the ThorVG C++ API, bringing native vector graphics rendering to Swift applications! πŸŽ‰

🌟 Highlights

ThorVGSwift provides two powerful ways to work with Lottie animations:

  • Low-Level API: Direct access to the rendering engine for frame-by-frame control
  • High-Level Views API: Ready-to-use SwiftUI and UIKit components with automatic playback

✨ Features

Core Functionality

  • βœ… Lottie animation rendering
  • βœ… LottieRenderer for low-level frame-by-frame control
  • βœ… Cross-platform: iOS 13.0+ and macOS 10.15+
  • βœ… SwiftUI LottieView component
  • βœ… UIKit LottieUIKitView component
  • βœ… LottieViewModel for state management

Playback Controls

  • βœ… Loop modes: Play once, loop, repeat N times, auto-reverse
  • βœ… Speed control (0.1x to 10x)
  • βœ… Seeking to frames or progress
  • βœ… Play, pause, stop controls

Rendering Options

  • βœ… Content modes: Aspect fit and fill
  • βœ… Flexible sizing with automatic intrinsic sizing
  • βœ… Multiple pixel formats (ARGB, RGBA, ABGR, BGRA)
  • βœ… Optional multi-threaded rendering

Developer Experience

  • βœ… Type-safe Swift API
  • βœ… Error handling via Combine
  • βœ… Real-time progress tracking
  • βœ… Pre-built XCFramework (no build steps!)
  • βœ… Sample app included
  • βœ… Complete documentation

πŸ“¦ Installation

Add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/thorvg/thorvg.swift", from: "0.1.0")
]

πŸš€ Quick Start

SwiftUI

import SwiftUI
import ThorVGSwift

struct ContentView: View {
    @StateObject private var viewModel: LottieViewModel
    
    init() {
        let lottie = try! Lottie(path: "animation.json")
        let config = LottieConfiguration(loopMode: .loop, speed: 1.0)
        _viewModel = StateObject(wrappedValue: LottieViewModel(
            lottie: lottie,
            configuration: config
        ))
    }
    
    var body: some View {
        LottieView(viewModel: viewModel)
            .onAppear { viewModel.play() }
    }
}

UIKit

import UIKit
import ThorVGSwift

class ViewController: UIViewController {
    private var viewModel: LottieViewModel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let lottie = try! Lottie(path: "animation.json")
        let config = LottieConfiguration(loopMode: .loop, speed: 1.0)
        
        viewModel = LottieViewModel(lottie: lottie, configuration: config)
        let lottieView = LottieUIKitView(viewModel: viewModel)
        
        view.addSubview(lottieView)
        viewModel.play()
    }
}

Low-Level API (Direct Rendering)

For advanced use cases requiring frame-by-frame control:

import ThorVGSwift

// Load Lottie animation
let lottie = try Lottie(path: "animation.json")

// Create a buffer for rendering
let size = CGSize(width: 1024, height: 1024)
var buffer = [UInt32](repeating: 0, count: Int(size.width * size.height))

// Initialize renderer
let renderer = LottieRenderer(
    lottie,
    size: size,
    buffer: &buffer,
    stride: Int(size.width),
    pixelFormat: .argb
)

// Render a specific frame
let contentRect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
try renderer.render(frameIndex: 0, contentRect: contentRect, rotation: 0.0)

// Buffer now contains the rendered frame data
// Iterate through lottie.numberOfFrames for full animation

The low-level API gives you complete control over:

  • Frame Selection: Render any frame on demand
  • Buffer Management: Bring your own buffer and pixel format
  • Multi-threading: Create custom Engine with multiple threads
  • Content Region: Render specific regions with custom cropping
  • Rotation: Apply rotation transforms during rendering

Perfect for custom video export, frame analysis, or integration with other rendering pipelines.

πŸ“š Documentation

πŸ”§ Technical Details

  • ThorVG Version: v1.0-pre32 (commit cf1557c)
  • Supported Platforms:
    • macOS: arm64 + x86_64 (Universal Binary)
    • iOS Device: arm64
    • iOS Simulator: arm64
  • Build System: Meson + Ninja
  • Distribution: Static library via XCFramework
  • Swift Version: 5.9+

⚠️ Known Limitations

  • Content Types: Currently only supports Lottie animations. SVG and other formats planned for future releases.
  • Threading: Multi-threading available but disabled by default on iOS/macOS to avoid OpenMP linking complexity with SPM.

πŸ™ Acknowledgments

Thanks to the ThorVG team for creating the amazing rendering engine, and to all early testers and contributors!

πŸ“ Full Changelog

See (thorvg.swift/docs/CHANGELOG.md) for complete details.

Known Limitations

  • Only Lottie animations are currently supported (SVG and other formats coming in future releases)
  • Threading disabled on iOS and macOS to avoid OpenMP linking issues with Swift Package Manager

πŸ› Reporting Issues

Found a bug? Please open an issue.

πŸ’¬ Community


Happy coding! πŸš€