A wrapper for libheif + Xcode project. Support Carthage && CocoaPods && SwiftPM.

libheif + Xcode

CI Status Version License Platform SwiftPM compatible Carthage compatible

A wrapper for libheif + Xcode project. This enables Carthage support to build libheif as a framework for Apple's platform.

This repo also including the CocoaPods's spec file to use libheif.


  • iOS 8+
  • macOS 10.10+
  • tvOS 9+
  • watchOS 2+



libheif is (via this repo) available through Carthage.

github "SDWebImage/libheif-Xcode"


libheif is available through CocoaPods.

pod 'libheif'

Swift Package Manager (Xcode 11+)

libheif is available through Swift Package Manager.

let package = Package(
    dependencies: [
        .package(url: "", from: "1.6.1")

HEIF Encoding

libheif itself is not a full function decoder but an abstract layer. It needs libde265 for HEIF decoder support, and x265 for HEIF encoder support.

For CocoaPods user, you can use libx265 subspec to integrate the x265 codec supports for HEIF encoding.

pod 'libavif', :subspecs => ['libde265', 'libx265']

Since most of people's usage of this library is for HEIF decoding, and x265 is under GPLv2 license, we only integrate libheif with the Carthage dependency libde265-Xcode. To use x265 for HEIF encoding, try to build it by your own.

AVIF Decoding

libheif from v1.7.0 added the support for AV1 Image File Format (AVIF). To keep the component functional, we only integrate the AVIF support in CocoaPods via libaom subspec.

pod 'libavif', :subspecs => ['libaom']

libheif from v1.9.0 added the support to use dav1d as AVIF decoder codec.

To use dav1d as decoder codec, use the subspec like this:

pod 'libavif', :subspecs => ['libdav1d']

AVIF Encoding

libheif from v1.7.0 added the support to use libaom as the default AVIF encoder codec. However, libaom performent so well on most mobile system.

There is another AVIF encoder codec, rav1e. Which added from v1.8.0 version. For CocoaPods, you can choose to use via librav1e subspec.

pod 'libavif', :subspecs => ['librav1e']


  1. rav1e supports iOS and macOS only, because Rust language does not supports tvOS or watchOS bitcode format.
  2. rav1e only supports AVIF encoding, for AVIF decoding, you can choose to use aom, or dav1d
pod 'libavif', :subspecs => ['libdav1d', 'librav1e']
# or if you prefer aom
pod 'libavif', :subspecs => ['libaom', 'librav1e']


libheif is available under the terms of the GNU Lesser General Public License. See the LICENSE file for more info.


  • Swift Tools 5.0.0
View More Packages from this Author


Last updated: Thu Mar 16 2023 19:56:50 GMT-0500 (GMT-05:00)