Awesome
libheif + Xcode
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.
Requirements
- iOS 9+
- macOS 10.11+
- tvOS 9+
- watchOS 2+
Installation
Carthage
libheif is (via this repo) available through Carthage.
github "SDWebImage/libheif-Xcode"
CocoaPods
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: "https://github.com/SDWebImage/libheif-Xcode.git", 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.
Note: Since most of people's usage of this library is for HEIF decoding, and x265
is under GPLv2 license, we only integrate libheif with libde265-Xcode on Carthage/SwiftPM package manager. If you want x265 with HEIF encoding support, read below carefully.
x265 on CocoaPods
For CocoaPods user, you can use libx265
subspec to integrate the x265 codec supports for HEIF encoding.
pod 'libheif', :subspecs => ['libde265', 'libx265']
x265 on Carthage
For Carthage user, export the environment (using bash profile or xcconfig if you want) HAVE_X265=1
, and modify carthage's xcconfig about GCC_PREPROCESSOR_DEFINITIONS
to build.
You can use the shell script to spawn carthage, like run via carthage_build_with_x265.sh build
#!/bin/bash -e
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
echo "GCC_PREPROCESSOR_DEFINITIONS = $(inherited) HAVE_X265=1" >> $xcconfig
export XCODE_XCCONFIG_FILE="$xcconfig"
carthage "$@"
x265 on SwiftPM
For SPM user, export the environment (using bash profile or xcconfig if you want) HAVE_X265=1
, and use xcodebuild
or swift build
to build.
mv libheif.xcodeproj libheif.xcodeproj.bak
HAVE_X265=1 xcodebuild build -scheme libheif -sdk macosx -destination "generic/platform=macOS"
AVIF Decoding
- aom
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 'libheif', :subspecs => ['libaom']
- dav1d
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 'libheif', :subspecs => ['libdav1d']
AVIF Encoding
- aom
libheif from v1.7.0 added the support to use libaom
as the default AVIF encoder codec. However, libaom does not performent so well on most mobile system.
pod 'libheif', :subspecs => ['libaom']
- rav1e
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 'libheif', :subspecs => ['librav1e']
Notes:
- rav1e supports iOS and macOS only, because Rust language does not supports tvOS or watchOS bitcode format.
- rav1e only supports AVIF encoding, for AVIF decoding, you can choose to use aom, or dav1d
pod 'libheif', :subspecs => ['libdav1d', 'librav1e']
# or if you prefer aom
pod 'libheif', :subspecs => ['libaom', 'librav1e']
- svt-av1
libheif from v1.14.0 added the support to use svt-av1 as AVIF decoder and encoder codec.
To use svt-av1 as encoder and decoder codec, use the subspec like this:
pod 'libheif', :subspecs => ['svt-av1']
License
libheif is available under the terms of the GNU Lesser General Public License. See the LICENSE file for more info.