diff --git a/.gitignore b/.gitignore index 5bf4abc..8b14304 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ Carthage/Build # `pod install` in .travis.yml # Pods/ + +# SwiftPM +.swiftpm +.build \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index f1f7d43..6333f8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10.2 +osx_image: xcode11 addons: homebrew: @@ -37,11 +37,12 @@ script: - pod lib lint --allow-warnings - echo Build as dynamic frameworks - - carthage update --platform ios,tvos,macos --configuration DEBUG + - carthage update --configuration DEBUG - xcodebuild build clean -project SDWebImagePDFCoder.xcodeproj -scheme 'SDWebImagePDFCoder iOS' -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Debug | xcpretty -c - xcodebuild build clean -project SDWebImagePDFCoder.xcodeproj -scheme 'SDWebImagePDFCoder tvOS' -sdk appletvsimulator -configuration Debug | xcpretty -c - xcodebuild build clean -project SDWebImagePDFCoder.xcodeproj -scheme 'SDWebImagePDFCoder macOS' -sdk macosx -configuration Debug | xcpretty -c + - xcodebuild build clean -project SDWebImagePDFCoder.xcodeproj -scheme 'SDWebImagePDFCoder watchOS' -sdk watchsimulator -configuration Debug | xcpretty -c - echo Build example - pod install --project-directory=Example - - xcodebuild build -workspace Example/SDWebImagePDFCoder.xcworkspace -scheme SDWebImagePDFCoder-Example -sdk iphonesimulator -destination 'name=iPhone 6s' -configuration Debug | xcpretty -c + - xcodebuild build -workspace Example/SDWebImagePDFCoder.xcworkspace -scheme SDWebImagePDFCoder-Example -sdk iphonesimulator -destination 'name=iPhone 8' -configuration Debug | xcpretty -c diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..d5a1c70 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "SDWebImage", + "repositoryURL": "https://github.com/SDWebImage/SDWebImage.git", + "state": { + "branch": null, + "revision": "7adc385b7d9aa758fb5073bcea478f31293c4e40", + "version": "5.3.1" + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..b3e4367 --- /dev/null +++ b/Package.swift @@ -0,0 +1,33 @@ +// 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: "SDWebImagePDFCoder", + 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: "SDWebImagePDFCoder", + targets: ["SDWebImagePDFCoder"]), + ], + 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") + ], + 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: "SDWebImagePDFCoder", + dependencies: ["SDWebImage"], + path: ".", + sources: ["SDWebImagePDFCoder/Classes"], + publicHeadersPath: "SDWebImagePDFCoder/Classes" + ) + ] +) diff --git a/README.md b/README.md index a827e4b..aeb62e2 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![License](https://img.shields.io/cocoapods/l/SDWebImagePDFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImagePDFCoder) [![Platform](https://img.shields.io/cocoapods/p/SDWebImagePDFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImagePDFCoder) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/SDWebImage/SDWebImagePDFCoder) +[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager/) ## What's for SDWebImagePDFCoder is a PDF coder plugin for [SDWebImage](https://github.com/rs/SDWebImage/) framework, which provide the image loading support for [PDF](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics). The PDF rendering is done using Apple's built-in framework (UIKit/AppKit/Core Graphics). @@ -17,9 +18,10 @@ You can modify the code or use some other PDF files to check the compatibility. ## Requirements -+ iOS 8 -+ tvOS 9 -+ macOS 10.10 ++ iOS 8+ ++ tvOS 9+ ++ macOS 10.10+ ++ watchOS 2+ ## Installation @@ -40,6 +42,18 @@ SDWebImagePDFCoder is available through [Carthage](https://github.com/Carthage/C github "SDWebImage/SDWebImagePDFCoder" ``` +#### Swift Package Manager (Xcode 11+) + +SDWebImagePDFCoder is available through [Swift Package Manager](https://swift.org/package-manager). + +```swift +let package = Package( + dependencies: [ + .package(url: "https://github.com/SDWebImage/SDWebImagePDFCoder.git", from: "0.4") + ] +) +``` + ## Usage To use PDF coder, you should firstly add the `SDImagePDFCoder` to the coders manager. Then you can call the View Category method to start load PDF images. diff --git a/SDWebImagePDFCoder.podspec b/SDWebImagePDFCoder.podspec index 1cbd4e2..1f3c749 100644 --- a/SDWebImagePDFCoder.podspec +++ b/SDWebImagePDFCoder.podspec @@ -29,6 +29,7 @@ SDWebImageSVGCoder is a SVG coder plugin for SDWebImage framework, which provide s.ios.deployment_target = '8.0' s.tvos.deployment_target = '9.0' s.osx.deployment_target = '10.10' + s.watchos.deployment_target = '2.0' s.source_files = 'SDWebImagePDFCoder/Classes/**/*', 'SDWebImagePDFCoder/Module/SDWebImagePDFCoder.h' s.module_map = 'SDWebImagePDFCoder/Module/SDWebImagePDFCoder.modulemap' diff --git a/SDWebImagePDFCoder.xcodeproj/project.pbxproj b/SDWebImagePDFCoder.xcodeproj/project.pbxproj index d3c8f9b..da33b8b 100644 --- a/SDWebImagePDFCoder.xcodeproj/project.pbxproj +++ b/SDWebImagePDFCoder.xcodeproj/project.pbxproj @@ -7,6 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + 32407BE123797C7E00F9AFA4 /* SDWebImagePDFCoderDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CA9EC82185BDC300322AF3 /* SDWebImagePDFCoderDefine.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 32407BE223797C7E00F9AFA4 /* SDWebImagePDFCoderDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = 32CA9ECB2185BDC300322AF3 /* SDWebImagePDFCoderDefine.m */; }; + 32407BE323797C7E00F9AFA4 /* SDImagePDFCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CA9ECA2185BDC300322AF3 /* SDImagePDFCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 32407BE423797C7E00F9AFA4 /* SDImagePDFCoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 32CA9ECC2185BDC300322AF3 /* SDImagePDFCoder.m */; }; + 32407BE523797C8E00F9AFA4 /* SDWebImagePDFCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CA9EC32185BDBB00322AF3 /* SDWebImagePDFCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 32407BE723797CAD00F9AFA4 /* SDWebImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32407BE623797CAD00F9AFA4 /* SDWebImage.framework */; }; 32CA9EC42185BDBB00322AF3 /* SDWebImagePDFCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CA9EC32185BDBB00322AF3 /* SDWebImagePDFCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; 32CA9EC52185BDBB00322AF3 /* SDWebImagePDFCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CA9EC32185BDBB00322AF3 /* SDWebImagePDFCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; 32CA9EC62185BDBB00322AF3 /* SDWebImagePDFCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 32CA9EC32185BDBB00322AF3 /* SDWebImagePDFCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -28,6 +34,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 32407BD923797C0400F9AFA4 /* SDWebImagePDFCoder.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImagePDFCoder.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 32407BE623797CAD00F9AFA4 /* SDWebImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDWebImage.framework; path = Carthage/Build/watchOS/SDWebImage.framework; sourceTree = ""; }; 32CA9E9C2185BC3D00322AF3 /* SDWebImagePDFCoder.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImagePDFCoder.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 32CA9EA72185BC7400322AF3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Module/Info.plist; sourceTree = ""; }; 32CA9EAE2185BCEA00322AF3 /* SDWebImagePDFCoder.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImagePDFCoder.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -43,6 +51,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 32407BD623797C0400F9AFA4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 32407BE723797CAD00F9AFA4 /* SDWebImage.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 32CA9E992185BC3D00322AF3 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -85,6 +101,7 @@ 32CA9E9C2185BC3D00322AF3 /* SDWebImagePDFCoder.framework */, 32CA9EAE2185BCEA00322AF3 /* SDWebImagePDFCoder.framework */, 32CA9EBB2185BD0700322AF3 /* SDWebImagePDFCoder.framework */, + 32407BD923797C0400F9AFA4 /* SDWebImagePDFCoder.framework */, ); name = Products; sourceTree = ""; @@ -113,6 +130,7 @@ 32CA9EDC2185BDEF00322AF3 /* Frameworks */ = { isa = PBXGroup; children = ( + 32407BE623797CAD00F9AFA4 /* SDWebImage.framework */, 32CA9EE12185BE0400322AF3 /* SDWebImage.framework */, 32CA9EDF2185BDFA00322AF3 /* SDWebImage.framework */, 32CA9EDD2185BDEF00322AF3 /* SDWebImage.framework */, @@ -123,6 +141,16 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 32407BD423797C0400F9AFA4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 32407BE323797C7E00F9AFA4 /* SDImagePDFCoder.h in Headers */, + 32407BE523797C8E00F9AFA4 /* SDWebImagePDFCoder.h in Headers */, + 32407BE123797C7E00F9AFA4 /* SDWebImagePDFCoderDefine.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 32CA9E972185BC3D00322AF3 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -156,6 +184,24 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 32407BD823797C0400F9AFA4 /* SDWebImagePDFCoder watchOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 32407BE023797C0400F9AFA4 /* Build configuration list for PBXNativeTarget "SDWebImagePDFCoder watchOS" */; + buildPhases = ( + 32407BD423797C0400F9AFA4 /* Headers */, + 32407BD523797C0400F9AFA4 /* Sources */, + 32407BD623797C0400F9AFA4 /* Frameworks */, + 32407BD723797C0400F9AFA4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "SDWebImagePDFCoder watchOS"; + productName = "SDWebImagePDFCoder watchOS"; + productReference = 32407BD923797C0400F9AFA4 /* SDWebImagePDFCoder.framework */; + productType = "com.apple.product-type.framework"; + }; 32CA9E9B2185BC3D00322AF3 /* SDWebImagePDFCoder iOS */ = { isa = PBXNativeTarget; buildConfigurationList = 32CA9EA42185BC3D00322AF3 /* Build configuration list for PBXNativeTarget "SDWebImagePDFCoder iOS" */; @@ -219,6 +265,9 @@ LastUpgradeCheck = 1000; ORGANIZATIONNAME = SDWebImagePDFCoder; TargetAttributes = { + 32407BD823797C0400F9AFA4 = { + CreatedOnToolsVersion = 11.2; + }; 32CA9E9B2185BC3D00322AF3 = { CreatedOnToolsVersion = 10.0; }; @@ -245,11 +294,19 @@ 32CA9E9B2185BC3D00322AF3 /* SDWebImagePDFCoder iOS */, 32CA9EAD2185BCEA00322AF3 /* SDWebImagePDFCoder tvOS */, 32CA9EBA2185BD0700322AF3 /* SDWebImagePDFCoder macOS */, + 32407BD823797C0400F9AFA4 /* SDWebImagePDFCoder watchOS */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 32407BD723797C0400F9AFA4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 32CA9E9A2185BC3D00322AF3 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -274,6 +331,15 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 32407BD523797C0400F9AFA4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 32407BE223797C7E00F9AFA4 /* SDWebImagePDFCoderDefine.m in Sources */, + 32407BE423797C7E00F9AFA4 /* SDImagePDFCoder.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 32CA9E982185BC3D00322AF3 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -304,6 +370,64 @@ /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ + 32407BDE23797C0400F9AFA4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/watchOS", + ); + INFOPLIST_FILE = "$(SRCROOT)/SDWebImagePDFCoder/Module/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.SDWebImagePDFCoder-watchOS"; + PRODUCT_NAME = SDWebImagePDFCoder; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Debug; + }; + 32407BDF23797C0400F9AFA4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/watchOS", + ); + INFOPLIST_FILE = "$(SRCROOT)/SDWebImagePDFCoder/Module/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.SDWebImagePDFCoder-watchOS"; + PRODUCT_NAME = SDWebImagePDFCoder; + SDKROOT = watchos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 2.0; + }; + name = Release; + }; 32CA9EA22185BC3D00322AF3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -599,6 +723,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 32407BE023797C0400F9AFA4 /* Build configuration list for PBXNativeTarget "SDWebImagePDFCoder watchOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 32407BDE23797C0400F9AFA4 /* Debug */, + 32407BDF23797C0400F9AFA4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 32CA9E962185BC3C00322AF3 /* Build configuration list for PBXProject "SDWebImagePDFCoder" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/SDWebImagePDFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImagePDFCoder watchOS.xcscheme b/SDWebImagePDFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImagePDFCoder watchOS.xcscheme new file mode 100644 index 0000000..5736d00 --- /dev/null +++ b/SDWebImagePDFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImagePDFCoder watchOS.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SDWebImagePDFCoder/Classes/SDImagePDFCoder.h b/SDWebImagePDFCoder/Classes/SDImagePDFCoder.h index a7cc0c9..666097e 100644 --- a/SDWebImagePDFCoder/Classes/SDImagePDFCoder.h +++ b/SDWebImagePDFCoder/Classes/SDImagePDFCoder.h @@ -5,7 +5,7 @@ // Created by lizhuoli on 2018/10/28. // -#import +@import SDWebImage; NS_ASSUME_NONNULL_BEGIN diff --git a/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m b/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m index 40cc4a3..665e636 100644 --- a/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m +++ b/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m @@ -11,7 +11,7 @@ #define SD_FOUR_CC(c1,c2,c3,c4) ((uint32_t)(((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1))) -#if SD_UIKIT +#if SD_UIKIT || SD_WATCH // iOS/tvOS 11+ UIImage add built-in vector PDF image support. So we use that instead of drawing bitmap image @interface UIImage (PrivatePDFSupport) @@ -58,10 +58,10 @@ - (UIImage *)decodedImageWithData:(NSData *)data options:(SDImageCoderOptions *) } if (context[SDWebImageContextPDFImageSize]) { NSValue *sizeValue = context[SDWebImageContextPDFImageSize]; -#if SD_UIKIT - imageSize = sizeValue.CGSizeValue; -#else +#if SD_MAC imageSize = sizeValue.sizeValue; +#else + imageSize = sizeValue.CGSizeValue; #endif } if (context[SDWebImageContextPDFImagePreserveAspectRatio]) { diff --git a/SDWebImagePDFCoder/Classes/SDWebImagePDFCoderDefine.h b/SDWebImagePDFCoder/Classes/SDWebImagePDFCoderDefine.h index 5e81a21..a03af19 100644 --- a/SDWebImagePDFCoder/Classes/SDWebImagePDFCoderDefine.h +++ b/SDWebImagePDFCoder/Classes/SDWebImagePDFCoderDefine.h @@ -5,7 +5,7 @@ // Created by lizhuoli on 2018/10/28. // -#import +@import SDWebImage; NS_ASSUME_NONNULL_BEGIN