Skip to content

Support SwiftPM for AVIFCoder #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ Carthage/Build
# `pod install` in .travis.yml
#
Pods/

# SwiftPM
.swiftpm
.build
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ notifications:
before_install:
- env
- locale
- brew install git-lfs
- git lfs install
- gem install cocoapods --no-document --quiet
- gem install xcpretty --no-document --quiet
- pod --version
Expand All @@ -23,6 +25,9 @@ before_install:
- xcodebuild -version
- xcodebuild -showsdks

before_script:
- git lfs pull

script:
- set -o pipefail

Expand Down
34 changes: 34 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SDWebImageAVIFCoder",
platforms: [
.macOS(.v10_10), .iOS(.v8), .tvOS(.v9), .watchOS(.v2)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SDWebImageAVIFCoder",
targets: ["SDWebImageAVIFCoder"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/SDWebImage/SDWebImage.git", from: "5.1.0"),
.package(url: "https://github.com/SDWebImage/libavif-Xcode.git", from: "0.5.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "SDWebImageAVIFCoder",
dependencies: ["SDWebImage", "libavif"],
path: ".",
sources: ["SDWebImageAVIFCoder/Classes"],
publicHeadersPath: "SDWebImageAVIFCoder/Classes"
)
]
)
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Version](https://img.shields.io/cocoapods/v/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)
[![License](https://img.shields.io/cocoapods/l/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)
[![Platform](https://img.shields.io/cocoapods/p/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager/)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/SDWebImage/SDWebImageAVIFCoder)

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

Carthage does not support like CocoaPods' subspec, it only supports libaom for AVIF decoding && encoding.

#### Swift Package Manager (Xcode 11+)

SDWebImageAVIFCoder is available through [Swift Package Manager](https://swift.org/package-manager).

The framework through SwiftPM only supports libaom for AVIF decoding && encoding.

```swift
let package = Package(
dependencies: [
.package(url: "https://github.com/SDWebImage/SDWebImageAVIF.git", from: "0.5")
]
)
```

## Usage

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.
Expand Down
4 changes: 4 additions & 0 deletions SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
// Created by lizhuoli on 2018/5/8.
//

#if __has_include(<SDWebImage/SDWebImage.h>)
#import <SDWebImage/SDWebImage.h>
#else
@import SDWebImage;
#endif

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

Expand Down
2 changes: 1 addition & 1 deletion SDWebImageAVIFCoder/Classes/SDImageAVIFCoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#if __has_include(<libavif/avif.h>)
#import <libavif/avif.h>
#else
#import "avif.h"
#import "avif/avif.h"
#endif

// Convert 8/10/12bit AVIF image into RGBA8888
Expand Down