Support SwiftPM

This commit is contained in:
DreamPiggy 2019-12-27 11:58:24 +08:00
parent f17326681a
commit 9cd65354eb
6 changed files with 74 additions and 7 deletions

6
.gitignore vendored
View File

@ -64,4 +64,8 @@ fastlane/test_output
# After new code Injection tools there's a generated folder /iOSInjectionProject # After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode # https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/ iOSInjectionProject/
# SwiftPM
.swiftpm
.build

25
Package.resolved Normal file
View File

@ -0,0 +1,25 @@
{
"object": {
"pins": [
{
"package": "libwebp",
"repositoryURL": "https://github.com/SDWebImage/libwebp-Xcode.git",
"state": {
"branch": null,
"revision": "cad41dc4f84bbf13bfe2f3acf85c58d1cb316ea0",
"version": "1.1.0-rc2"
}
},
{
"package": "SDWebImage",
"repositoryURL": "https://github.com/SDWebImage/SDWebImage.git",
"state": {
"branch": null,
"revision": "7ef9a314b12c1a31edb0d09d41fcba93143fe772",
"version": "5.4.0"
}
}
]
},
"version": 1
}

34
Package.swift Normal file
View File

@ -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: "SDWebImageWebPCoder",
platforms: [
.macOS(.v10_13), .iOS(.v8), .tvOS(.v10)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SDWebImageWebPCoder",
targets: ["SDWebImageWebPCoder"]),
],
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/libwebp-Xcode.git", from: Version(1, 1, 0, prereleaseIdentifiers: ["-rc.2"]))
],
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: "SDWebImageWebPCoder",
dependencies: ["SDWebImage", "libwebp"],
path: ".",
sources: ["SDWebImageWebPCoder/Classes"],
publicHeadersPath: "SDWebImageWebPCoder/Classes"
)
]
)

View File

@ -6,7 +6,11 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
#if __has_include(<SDWebImage/SDWebImage.h>)
#import <SDWebImage/SDWebImage.h> #import <SDWebImage/SDWebImage.h>
#else
@import SDWebImage;
#endif
/** /**
Built in coder that supports WebP and animated WebP Built in coder that supports WebP and animated WebP

View File

@ -7,12 +7,6 @@
*/ */
#import "SDImageWebPCoder.h" #import "SDImageWebPCoder.h"
#import <SDWebImage/SDImageCoderHelper.h>
#if __has_include(<SDWebImage/NSImage+Compatibility.h>)
#import <SDWebImage/NSImage+Compatibility.h>
#endif
#import <SDWebImage/UIImage+Metadata.h>
#import <SDWebImage/UIImage+ForceDecode.h>
#if __has_include("webp/decode.h") && __has_include("webp/encode.h") && __has_include("webp/demux.h") && __has_include("webp/mux.h") #if __has_include("webp/decode.h") && __has_include("webp/encode.h") && __has_include("webp/demux.h") && __has_include("webp/mux.h")
#import "webp/decode.h" #import "webp/decode.h"
@ -24,6 +18,8 @@
#import <libwebp/encode.h> #import <libwebp/encode.h>
#import <libwebp/demux.h> #import <libwebp/demux.h>
#import <libwebp/mux.h> #import <libwebp/mux.h>
#else
@import libwebp;
#endif #endif
#import <Accelerate/Accelerate.h> #import <Accelerate/Accelerate.h>

View File

@ -6,7 +6,11 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
#if __has_include(<SDWebImage/SDWebImage.h>)
#import <SDWebImage/SDWebImage.h> #import <SDWebImage/SDWebImage.h>
#else
@import SDWebImage;
#endif
// This category is just use as a convenience method. For more detail control, use methods in `UIImage+MultiFormat.h` or directlly use `SDImageCoder` // This category is just use as a convenience method. For more detail control, use methods in `UIImage+MultiFormat.h` or directlly use `SDImageCoder`
@interface UIImage (WebP) @interface UIImage (WebP)