Skip to content

Commit aa07c56

Browse files
authored
Merge pull request #8 from SDWebImage/swiftpm
Support SwiftPM for AVIFCoder
2 parents ca147aa + 1c3e2a1 commit aa07c56

File tree

7 files changed

+99
-1
lines changed

7 files changed

+99
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ Carthage/Build
3434
# `pod install` in .travis.yml
3535
#
3636
Pods/
37+
38+
# SwiftPM
39+
.swiftpm
40+
.build

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ notifications:
1515
before_install:
1616
- env
1717
- locale
18+
- brew install git-lfs
19+
- git lfs install
1820
- gem install cocoapods --no-document --quiet
1921
- gem install xcpretty --no-document --quiet
2022
- pod --version
@@ -23,6 +25,9 @@ before_install:
2325
- xcodebuild -version
2426
- xcodebuild -showsdks
2527

28+
before_script:
29+
- git lfs pull
30+
2631
script:
2732
- set -o pipefail
2833

Package.resolved

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// swift-tools-version:5.0
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SDWebImageAVIFCoder",
8+
platforms: [
9+
.macOS(.v10_10), .iOS(.v8), .tvOS(.v9), .watchOS(.v2)
10+
],
11+
products: [
12+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
13+
.library(
14+
name: "SDWebImageAVIFCoder",
15+
targets: ["SDWebImageAVIFCoder"]),
16+
],
17+
dependencies: [
18+
// Dependencies declare other packages that this package depends on.
19+
// .package(url: /* package url */, from: "1.0.0"),
20+
.package(url: "https://github.com/SDWebImage/SDWebImage.git", from: "5.1.0"),
21+
.package(url: "https://github.com/SDWebImage/libavif-Xcode.git", from: "0.5.0")
22+
],
23+
targets: [
24+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
25+
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
26+
.target(
27+
name: "SDWebImageAVIFCoder",
28+
dependencies: ["SDWebImage", "libavif"],
29+
path: ".",
30+
sources: ["SDWebImageAVIFCoder/Classes"],
31+
publicHeadersPath: "SDWebImageAVIFCoder/Classes"
32+
)
33+
]
34+
)

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Version](https://img.shields.io/cocoapods/v/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)
55
[![License](https://img.shields.io/cocoapods/l/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)
66
[![Platform](https://img.shields.io/cocoapods/p/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)
7+
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager/)
78
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/SDWebImage/SDWebImageAVIFCoder)
89

910
## What's for
@@ -83,6 +84,22 @@ SDWebImageAVIFCoder is available through [Carthage](https://github.com/Carthage/
8384
github "SDWebImage/SDWebImageAVIFCoder"
8485
```
8586

87+
Carthage does not support like CocoaPods' subspec, it only supports libaom for AVIF decoding && encoding.
88+
89+
#### Swift Package Manager (Xcode 11+)
90+
91+
SDWebImageAVIFCoder is available through [Swift Package Manager](https://swift.org/package-manager).
92+
93+
The framework through SwiftPM only supports libaom for AVIF decoding && encoding.
94+
95+
```swift
96+
let package = Package(
97+
dependencies: [
98+
.package(url: "https://github.com/SDWebImage/SDWebImageAVIF.git", from: "0.5")
99+
]
100+
)
101+
```
102+
86103
## Usage
87104

88105
To use AVIF coder, you should firstly add the `SDImageAVIFCoder.sharedCoder` to the coders manager. Then you can call the View Category method to start load AVIF images.

SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
// Created by lizhuoli on 2018/5/8.
66
//
77

8+
#if __has_include(<SDWebImage/SDWebImage.h>)
89
#import <SDWebImage/SDWebImage.h>
10+
#else
11+
@import SDWebImage;
12+
#endif
913

1014
static const SDImageFormat SDImageFormatAVIF = 15; // AV1-codec based HEIF
1115

SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#if __has_include(<libavif/avif.h>)
1111
#import <libavif/avif.h>
1212
#else
13-
#import "avif.h"
13+
#import "avif/avif.h"
1414
#endif
1515

1616
// Convert 8/10/12bit AVIF image into RGBA8888

0 commit comments

Comments
 (0)