https://github.com/sdwebimage/libheif-xcode
A wrapper for libheif + Xcode project. Support Carthage && CocoaPods && SwiftPM.
https://github.com/sdwebimage/libheif-xcode
carthage heif hevc ios macos swiftpm tvos watchos
Last synced: 18 days ago
JSON representation
A wrapper for libheif + Xcode project. Support Carthage && CocoaPods && SwiftPM.
- Host: GitHub
- URL: https://github.com/sdwebimage/libheif-xcode
- Owner: SDWebImage
- Created: 2018-12-22T08:34:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-12T11:02:35.000Z (11 months ago)
- Last Synced: 2025-06-04T03:26:17.277Z (24 days ago)
- Topics: carthage, heif, hevc, ios, macos, swiftpm, tvos, watchos
- Language: Ruby
- Homepage:
- Size: 564 KB
- Stars: 12
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# libheif + Xcode
[](https://travis-ci.org/SDWebImage/libheif-Xcode)
[](http://cocoapods.org/pods/libheif)
[](http://cocoapods.org/pods/libheif)
[](http://cocoapods.org/pods/libheif)
[](https://swift.org/package-manager/)
[](https://github.com/SDWebImage/libheif-Xcode)A wrapper for [libheif](https://github.com/strukturag/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](https://github.com/Carthage/Carthage).
```
github "SDWebImage/libheif-Xcode"
```### CocoaPods
libheif is available through [CocoaPods](https://github.com/CocoaPods/CocoaPods).
```
pod 'libheif'
```#### Swift Package Manager (Xcode 11+)
libheif is available through [Swift Package Manager](https://swift.org/package-manager).
```swift
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](http://www.libde265.org/) for HEIF decoder support, and [x265](http://x265.org/) 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](https://github.com/SDWebImage/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.
```ruby
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`
```bash
#!/bin/bash -e
xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
echo "GCC_PREPROCESSOR_DEFINITIONS = $(inherited) HAVE_X265=1" >> $xcconfigexport 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.
```bash
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)](https://aomediacodec.github.io/av1-avif). To keep the component functional, we only integrate the AVIF support in CocoaPods via `libaom` subspec.
```ruby
pod 'libheif', :subspecs => ['libaom']
```+ dav1d
libheif from v1.9.0 added the support to use [dav1d](https://code.videolan.org/videolan/dav1d) as AVIF decoder codec.
To use dav1d as decoder codec, use the subspec like this:
```ruby
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.
```ruby
pod 'libheif', :subspecs => ['libaom']
```+ rav1e
There is another AVIF encoder codec, [rav1e](https://github.com/xiph/rav1e). Which added from v1.8.0 version. For CocoaPods, you can choose to use via `librav1e` subspec.
```ruby
pod 'libheif', :subspecs => ['librav1e']
```Notes:
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```ruby
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](https://gitlab.com/AOMediaCodec/SVT-AV1) as AVIF decoder and encoder codec.
To use svt-av1 as encoder and decoder codec, use the subspec like this:
```ruby
pod 'libheif', :subspecs => ['svt-av1']
```## License
libheif is available under the terms of the GNU Lesser General Public License. See [the LICENSE file](https://github.com/strukturag/libheif/blob/master/COPYING) for more info.