Skip to content

Drop SVGKit support to another repo, using iOS 13/macOS 10.15 native CoreSVG instead #10

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 12 commits into from
Nov 13, 2019
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
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

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

7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode10.2
osx_image: xcode11

addons:
homebrew:
Expand Down Expand Up @@ -37,12 +37,13 @@ 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 SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder iOS' -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Debug | xcpretty -c
- xcodebuild build clean -project SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder tvOS' -sdk appletvsimulator -configuration Debug | xcpretty -c
- xcodebuild build clean -project SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder macOS' -sdk macosx -configuration Debug | xcpretty -c
- xcodebuild build clean -project SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder watchOS' -sdk watchsimulator -configuration Debug | xcpretty -c

- echo Build example
- pod install --project-directory=Example
- xcodebuild build -workspace Example/SDWebImageSVGCoder.xcworkspace -scheme 'SDWebImageSVGCoder-Example' -sdk iphonesimulator -destination 'name=iPhone 6s' -configuration Debug | xcpretty -c
- xcodebuild build -workspace Example/SDWebImageSVGCoder.xcworkspace -scheme 'SDWebImageSVGCoder-Example' -sdk iphonesimulator -destination 'name=iPhone 8' -configuration Debug | xcpretty -c
- xcodebuild build -workspace Example/SDWebImageSVGCoder.xcworkspace -scheme 'SDWebImageSVGCoder-Example macOS' -sdk macosx -configuration Debug | xcpretty -c
3 changes: 1 addition & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github "SDWebImage/SDWebImage" ~> 5.0
github "SVGKit/SVGKit" >= 2.1
github "SDWebImage/SDWebImage" ~> 5.0
4 changes: 1 addition & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
github "CocoaLumberjack/CocoaLumberjack" "3.5.2"
github "SDWebImage/SDWebImage" "5.0.0"
github "SVGKit/SVGKit" "2.1.0"
github "SDWebImage/SDWebImage" "5.3.1"
5 changes: 2 additions & 3 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use_frameworks!

target 'SDWebImageSVGCoder_Example' do
platform :ios, '9.3'
platform :ios, '13.0'
pod 'SDWebImageSVGCoder', :path => '../'
pod 'SVGKit', :git => 'https://github.com/SVGKit/SVGKit.git', :branch => '3.x'

target 'SDWebImageSVGCoder_Tests' do
inherit! :search_paths
Expand All @@ -13,6 +12,6 @@ target 'SDWebImageSVGCoder_Example' do
end

target 'SDWebImageSVGCoder_Example macOS' do
platform :osx, '10.13'
platform :osx, '10.15'
pod 'SDWebImageSVGCoder', :path => '../'
end
32 changes: 7 additions & 25 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
PODS:
- CocoaLumberjack (3.5.3):
- CocoaLumberjack/Core (= 3.5.3)
- CocoaLumberjack/Core (3.5.3)
- SDWebImage/Core (5.0.2)
- SDWebImageSVGCoder (0.2.0):
- SDWebImage/Core (5.3.1)
- SDWebImageSVGCoder (0.3.0):
- SDWebImage/Core (~> 5.0)
- SVGKit (>= 2.1)
- SVGKit (2.1.0):
- CocoaLumberjack (~> 3.0)

DEPENDENCIES:
- SDWebImageSVGCoder (from `../`)
- SVGKit (from `https://github.com/SVGKit/SVGKit.git`, branch `3.x`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- CocoaLumberjack
trunk:
- SDWebImage

EXTERNAL SOURCES:
SDWebImageSVGCoder:
:path: "../"
SVGKit:
:branch: 3.x
:git: https://github.com/SVGKit/SVGKit.git

CHECKOUT OPTIONS:
SVGKit:
:commit: cf32da55633e370e66a7ba6e003224bd67296c16
:git: https://github.com/SVGKit/SVGKit.git

SPEC CHECKSUMS:
CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
SDWebImage: 6764b5fa0f73c203728052955dbefa2bf1f33282
SDWebImageSVGCoder: 61f60a3064db079de646a34a5f5aa8d3ac258345
SVGKit: 8a2fc74258bdb2abb54d3b65f3dd68b0277a9c4d
SDWebImage: 7137d57385fb632129838c1e6ab9528a22c666cc
SDWebImageSVGCoder: 23a0505a7d34193abf93e9c1afda1dd5c12134d4

PODFILE CHECKSUM: 8107c7193dd0c4844a782937610f415caa6ef482
PODFILE CHECKSUM: 84f51f25230f3de246edc2d26479a6b409c99fb1

COCOAPODS: 1.6.1
COCOAPODS: 1.8.4
14 changes: 8 additions & 6 deletions Example/SDWebImageSVGCoder-Example-macOS/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,30 @@ - (void)viewDidLoad {
// Do any additional setup after loading the view.
SDImageSVGCoder *SVGCoder = [SDImageSVGCoder sharedCoder];
[[SDImageCodersManager sharedManager] addCoder:SVGCoder];
NSURL *SVGURL = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/1/14/Mahuri.svg"];
NSURL *SVGURL2 = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/6/67/Firefox_Logo%2C_2017.svg"];
NSURL *svgURL = [NSURL URLWithString:@"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/w3c.svg"];
NSURL *svgURL2 = [NSURL URLWithString:@"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/wikimedia.svg"];

CGSize screenSize = self.view.bounds.size;

SVGKImageView *imageView1 = [[SVGKFastImageView alloc] initWithSVGKImage:nil];
UIImageView *imageView1 = [[UIImageView alloc] init];
imageView1.frame = CGRectMake(0, 0, screenSize.width / 2, screenSize.height);
imageView1.imageScaling = NSImageScaleProportionallyUpOrDown;

SVGKImageView *imageView2 = [[SVGKLayeredImageView alloc] initWithSVGKImage:nil];
UIImageView *imageView2 = [[UIImageView alloc] init];
imageView2.frame = CGRectMake(screenSize.width / 2, 0, screenSize.width / 2, screenSize.height);
imageView2.imageScaling = NSImageScaleProportionallyUpOrDown;

[self.view addSubview:imageView1];
[self.view addSubview:imageView2];

[imageView1 sd_setImageWithURL:SVGURL placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
[imageView1 sd_setImageWithURL:svgURL placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
NSLog(@"SVG load success");
NSData *svgData = [image sd_imageDataAsFormat:SDImageFormatSVG];
NSAssert(svgData.length > 0, @"SVG Data should exist");
}
}];
[imageView2 sd_setImageWithURL:SVGURL2 placeholderImage:nil options:SDWebImageRetryFailed context:@{SDWebImageContextSVGImageSize : @(imageView2.bounds.size)} progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
[imageView2 sd_setImageWithURL:svgURL2 placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
NSLog(@"SVG load animation success");
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
Expand Down
12 changes: 0 additions & 12 deletions Example/SDWebImageSVGCoder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,13 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSVGCoder_Example/Pods-SDWebImageSVGCoder_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CocoaLumberjack-iOS/CocoaLumberjack.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImage-iOS/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-iOS/SDWebImageSVGCoder.framework",
"${BUILT_PRODUCTS_DIR}/SVGKit-iOS/SVGKit.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaLumberjack.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVGKit.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -451,23 +447,15 @@
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSVGCoder_Example macOS/Pods-SDWebImageSVGCoder_Example macOS-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CocoaLumberjack-macOS/CocoaLumberjack.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImage-macOS/SDWebImage.framework",
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-macOS/SDWebImageSVGCoder.framework",
"${BUILT_PRODUCTS_DIR}/SVGKit-macOS/SVGKit.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
);
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaLumberjack.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVGKit.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
<dict>
<key>BuildSystemType</key>
<string>Original</string>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
31 changes: 16 additions & 15 deletions Example/SDWebImageSVGCoder/SDViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import "SDViewController.h"
#import <SDWebImageSVGCoder/SDWebImageSVGCoder.h>
#import <SVGKit/SVGKit.h>

@interface SDViewController ()

Expand All @@ -23,26 +22,22 @@ - (void)viewDidLoad

SDImageSVGCoder *SVGCoder = [SDImageSVGCoder sharedCoder];
[[SDImageCodersManager sharedManager] addCoder:SVGCoder];
NSURL *svgURL = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/1/14/Mahuri.svg"];
NSURL *svgURL2 = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/2/2d/Sample_SVG_file%2C_signature.svg"];
NSURL *svgURL = [NSURL URLWithString:@"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/w3c.svg"];
NSURL *svgURL2 = [NSURL URLWithString:@"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/wikimedia.svg"];
NSURL *svgURL3 = [NSURL URLWithString:@"https://simpleicons.org/icons/github.svg"];

CGSize screenSize = [UIScreen mainScreen].bounds.size;

// `SVGKLayeredImageView`, best on performance and do actually vector image rendering (translate SVG to CALayer tree).
SVGKImageView *imageView1 = [[SVGKLayeredImageView alloc] initWithSVGKImage:nil];
UIImageView *imageView1 = [[UIImageView alloc] init];
imageView1.frame = CGRectMake(0, 0, screenSize.width, screenSize.height / 2);
imageView1.sd_adjustContentMode = YES; // make `contentMode` works
imageView1.contentMode = UIViewContentModeScaleAspectFill;
imageView1.clipsToBounds = YES;
imageView1.contentMode = UIViewContentModeScaleAspectFit;

// `SVGKFastImageView`, draw SVG as bitmap dynamically when size changed.
SVGKImageView *imageView2 = [[SVGKFastImageView alloc] initWithSVGKImage:nil];
UIImageView *imageView2 = [[UIImageView alloc] init];
imageView2.frame = CGRectMake(0, screenSize.height / 2, screenSize.width, screenSize.height / 2);
imageView2.clipsToBounds = YES;
imageView2.contentMode = UIViewContentModeScaleAspectFill;

// `UIImageView`, draw SVG as bitmap image with fixed size, like PNG.
UIImageView *imageView3 = [[UIImageView alloc] initWithFrame:CGRectMake(screenSize.width - 100, screenSize.height - 100, 100, 100)];
imageView2.contentMode = UIViewContentModeScaleToFill;

[self.view addSubview:imageView1];
[self.view addSubview:imageView2];
Expand All @@ -60,10 +55,16 @@ - (void)viewDidLoad
NSLog(@"SVGKFastImageView SVG load success");
}
}];
// For `UIImageView`, you can specify a desired SVG size instead of original SVG viewport (which may be small)
[imageView3 sd_setImageWithURL:svgURL3 placeholderImage:nil options:SDWebImageRetryFailed context:@{SDWebImageContextSVGImageSize : @(CGSizeMake(100, 100))} progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
[imageView3 sd_setImageWithURL:svgURL3 placeholderImage:nil options:SDWebImageRetryFailed context:nil progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (image) {
NSLog(@"UIImageView SVG load success");
NSLog(@"SVG load animation success");
[UIView animateWithDuration:2 animations:^{
imageView3.bounds = CGRectMake(0, 0, 300, 300);
} completion:^(BOOL finished) {
[UIView animateWithDuration:2 animations:^{
imageView3.bounds = CGRectMake(0, 0, 100, 100);
}];
}];
}
}];
}
Expand Down
Binary file modified Example/Screenshot/SVGDemo-macOS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Screenshot/SVGDemo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -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
}
33 changes: 33 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SDWebImageSVGCoder",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "SDWebImageSVGCoder",
targets: ["SDWebImageSVGCoder"]),
],
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: "SDWebImageSVGCoder",
dependencies: ["SDWebImage"],
path: ".",
sources: ["SDWebImageSVGCoder/Classes"],
publicHeadersPath: "SDWebImageSVGCoder/Classes"
)
]
)
Loading