diff --git a/.gitignore b/.gitignore index 2228df1..23eaadf 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,8 @@ fastlane/test_output # After new code Injection tools there's a generated folder /iOSInjectionProject # https://github.com/johnno1962/injectionforxcode -iOSInjectionProject/ \ No newline at end of file +iOSInjectionProject/ + +# SwiftPM +.swiftpm +.build diff --git a/.travis.yml b/.travis.yml index b900c97..0d691a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode9.4 +osx_image: xcode11.2 env: global: @@ -15,10 +15,9 @@ notifications: before_install: - env - locale - - gem install cocoapods --no-rdoc --no-ri --no-document --quiet - - gem install xcpretty --no-rdoc --no-ri --no-document --quiet + - gem install cocoapods --no-document --quiet + - gem install xcpretty --no-document --quiet - pod --version - - pod setup --silent > /dev/null - pod repo update --silent - xcpretty --version - xcodebuild -version @@ -32,13 +31,15 @@ script: - echo Build example - pod install --project-directory=Example - - xcodebuild build clean -workspace SDWebImageWebPCoder.xcworkspace -scheme SDWebImageWebPCoderExample -sdk iphonesimulator -destination 'name=iPhone 6s' -configuration Debug | xcpretty -c + - xcodebuild build clean -workspace SDWebImageWebPCoder.xcworkspace -scheme SDWebImageWebPCoderExample -sdk iphonesimulator -destination 'name=iPhone 11 Pro' -configuration Debug | xcpretty -c + - echo Clean DerivedData + - rm -rf ~/Library/Developer/Xcode/DerivedData/ - mkdir DerivedData - echo Run the tests - pod install --project-directory=SDWebImageWebPCoderTests - - xcodebuild test -workspace SDWebImageWebPCoder.xcworkspace -scheme 'SDWebImageWebPCoderTests' -sdk iphonesimulator -destination 'name=iPhone 6s' -configuration Debug | xcpretty -c + - xcodebuild clean test -workspace SDWebImageWebPCoder.xcworkspace -scheme 'SDWebImageWebPCoderTests' -sdk iphonesimulator -destination 'name=iPhone 11 Pro' -configuration Debug -UseModernBuildSystem=NO | xcpretty -c - mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/iOS after_success: diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..665c98d --- /dev/null +++ b/Package.resolved @@ -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 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..295f103 --- /dev/null +++ b/Package.swift @@ -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_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: "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" + ) + ] +) diff --git a/README.md b/README.md index 937f156..00875c3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![Version](https://img.shields.io/cocoapods/v/SDWebImageWebPCoder.svg?style=flat)](http://cocoapods.org/pods/SDWebImageWebPCoder) [![License](https://img.shields.io/cocoapods/l/SDWebImageWebPCoder.svg?style=flat)](http://cocoapods.org/pods/SDWebImageWebPCoder) [![Platform](https://img.shields.io/cocoapods/p/SDWebImageWebPCoder.svg?style=flat)](http://cocoapods.org/pods/SDWebImageWebPCoder) +[![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/SDWebImageWebPCoder) Starting with the SDWebImage 5.0 version, we moved the WebP support code and [libwebp](https://github.com/webmproject/libwebp) from the Core Repo to this stand-alone repo. @@ -35,6 +36,18 @@ SDWebImageWebPCoder is available through [Carthage](https://github.com/Carthage/ github "SDWebImage/SDWebImageWebPCoder" ``` +#### Swift Package Manager (Xcode 11+) + +SDWebImageWebPCoder is available through [Swift Package Manager](https://swift.org/package-manager). + +```swift +let package = Package( + dependencies: [ + .package(url: "https://github.com/SDWebImage/SDWebImageWebPCoder.git", from: "0.3.0") + ] +) +``` + ## Usage ### Add Coder diff --git a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.h b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.h index ca6e7f2..7629ded 100644 --- a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.h +++ b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.h @@ -6,7 +6,11 @@ * file that was distributed with this source code. */ +#if __has_include() #import +#else +@import SDWebImage; +#endif /** Built in coder that supports WebP and animated WebP diff --git a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m index 1ff3b7a..6b06059 100644 --- a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m +++ b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m @@ -7,12 +7,6 @@ */ #import "SDImageWebPCoder.h" -#import -#if __has_include() -#import -#endif -#import -#import #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" @@ -24,6 +18,8 @@ #import #import #import +#else +@import libwebp; #endif #import diff --git a/SDWebImageWebPCoder/Classes/UIImage+WebP.h b/SDWebImageWebPCoder/Classes/UIImage+WebP.h index 1e4b0f5..068b305 100644 --- a/SDWebImageWebPCoder/Classes/UIImage+WebP.h +++ b/SDWebImageWebPCoder/Classes/UIImage+WebP.h @@ -6,7 +6,11 @@ * file that was distributed with this source code. */ +#if __has_include() #import +#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` @interface UIImage (WebP) diff --git a/SDWebImageWebPCoderTests/SDWebImageWebPCoderTests.m b/SDWebImageWebPCoderTests/SDWebImageWebPCoderTests.m index c20e24e..f895071 100644 --- a/SDWebImageWebPCoderTests/SDWebImageWebPCoderTests.m +++ b/SDWebImageWebPCoderTests/SDWebImageWebPCoderTests.m @@ -105,7 +105,6 @@ const int64_t kAsyncTestTimeout = 5; SDAnimatedImage *image = [SDAnimatedImage imageWithData:animatedImageData]; imageView.image = image; XCTAssertNotNil(imageView.image); - XCTAssertNotNil(imageView.currentFrame); // current frame } - (void)test32AnimatedImageViewCategoryProgressive {