Skip to content

Commit aabf0ca

Browse files
authored
Merge pull request #10 from SDWebImage/iOS13_SVG
Drop SVGKit support to another repo, using iOS 13/macOS 10.15 native CoreSVG instead
2 parents 1601cdf + ec7a344 commit aabf0ca

File tree

27 files changed

+453
-843
lines changed

27 files changed

+453
-843
lines changed

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode10.2
2+
osx_image: xcode11
33

44
addons:
55
homebrew:
@@ -37,12 +37,13 @@ script:
3737
- pod lib lint --allow-warnings
3838

3939
- echo Build as dynamic frameworks
40-
- carthage update --platform ios,tvos,macos --configuration DEBUG
40+
- carthage update --configuration DEBUG
4141
- xcodebuild build clean -project SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder iOS' -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Debug | xcpretty -c
4242
- xcodebuild build clean -project SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder tvOS' -sdk appletvsimulator -configuration Debug | xcpretty -c
4343
- xcodebuild build clean -project SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder macOS' -sdk macosx -configuration Debug | xcpretty -c
44+
- xcodebuild build clean -project SDWebImageSVGCoder.xcodeproj -scheme 'SDWebImageSVGCoder watchOS' -sdk watchsimulator -configuration Debug | xcpretty -c
4445

4546
- echo Build example
4647
- pod install --project-directory=Example
47-
- xcodebuild build -workspace Example/SDWebImageSVGCoder.xcworkspace -scheme 'SDWebImageSVGCoder-Example' -sdk iphonesimulator -destination 'name=iPhone 6s' -configuration Debug | xcpretty -c
48+
- xcodebuild build -workspace Example/SDWebImageSVGCoder.xcworkspace -scheme 'SDWebImageSVGCoder-Example' -sdk iphonesimulator -destination 'name=iPhone 8' -configuration Debug | xcpretty -c
4849
- xcodebuild build -workspace Example/SDWebImageSVGCoder.xcworkspace -scheme 'SDWebImageSVGCoder-Example macOS' -sdk macosx -configuration Debug | xcpretty -c

Cartfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
github "SDWebImage/SDWebImage" ~> 5.0
2-
github "SVGKit/SVGKit" >= 2.1
1+
github "SDWebImage/SDWebImage" ~> 5.0

Cartfile.resolved

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
github "CocoaLumberjack/CocoaLumberjack" "3.5.2"
2-
github "SDWebImage/SDWebImage" "5.0.0"
3-
github "SVGKit/SVGKit" "2.1.0"
1+
github "SDWebImage/SDWebImage" "5.3.1"

Example/Podfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use_frameworks!
22

33
target 'SDWebImageSVGCoder_Example' do
4-
platform :ios, '9.3'
4+
platform :ios, '13.0'
55
pod 'SDWebImageSVGCoder', :path => '../'
6-
pod 'SVGKit', :git => 'https://github.com/SVGKit/SVGKit.git', :branch => '3.x'
76

87
target 'SDWebImageSVGCoder_Tests' do
98
inherit! :search_paths
@@ -13,6 +12,6 @@ target 'SDWebImageSVGCoder_Example' do
1312
end
1413

1514
target 'SDWebImageSVGCoder_Example macOS' do
16-
platform :osx, '10.13'
15+
platform :osx, '10.15'
1716
pod 'SDWebImageSVGCoder', :path => '../'
1817
end

Example/Podfile.lock

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
11
PODS:
2-
- CocoaLumberjack (3.5.3):
3-
- CocoaLumberjack/Core (= 3.5.3)
4-
- CocoaLumberjack/Core (3.5.3)
5-
- SDWebImage/Core (5.0.2)
6-
- SDWebImageSVGCoder (0.2.0):
2+
- SDWebImage/Core (5.3.1)
3+
- SDWebImageSVGCoder (0.3.0):
74
- SDWebImage/Core (~> 5.0)
8-
- SVGKit (>= 2.1)
9-
- SVGKit (2.1.0):
10-
- CocoaLumberjack (~> 3.0)
115

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

169
SPEC REPOS:
17-
https://github.com/cocoapods/specs.git:
18-
- CocoaLumberjack
10+
trunk:
1911
- SDWebImage
2012

2113
EXTERNAL SOURCES:
2214
SDWebImageSVGCoder:
2315
:path: "../"
24-
SVGKit:
25-
:branch: 3.x
26-
:git: https://github.com/SVGKit/SVGKit.git
27-
28-
CHECKOUT OPTIONS:
29-
SVGKit:
30-
:commit: cf32da55633e370e66a7ba6e003224bd67296c16
31-
:git: https://github.com/SVGKit/SVGKit.git
3216

3317
SPEC CHECKSUMS:
34-
CocoaLumberjack: 2f44e60eb91c176d471fdba43b9e3eae6a721947
35-
SDWebImage: 6764b5fa0f73c203728052955dbefa2bf1f33282
36-
SDWebImageSVGCoder: 61f60a3064db079de646a34a5f5aa8d3ac258345
37-
SVGKit: 8a2fc74258bdb2abb54d3b65f3dd68b0277a9c4d
18+
SDWebImage: 7137d57385fb632129838c1e6ab9528a22c666cc
19+
SDWebImageSVGCoder: 23a0505a7d34193abf93e9c1afda1dd5c12134d4
3820

39-
PODFILE CHECKSUM: 8107c7193dd0c4844a782937610f415caa6ef482
21+
PODFILE CHECKSUM: 84f51f25230f3de246edc2d26479a6b409c99fb1
4022

41-
COCOAPODS: 1.6.1
23+
COCOAPODS: 1.8.4

Example/SDWebImageSVGCoder-Example-macOS/ViewController.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,30 @@ - (void)viewDidLoad {
1818
// Do any additional setup after loading the view.
1919
SDImageSVGCoder *SVGCoder = [SDImageSVGCoder sharedCoder];
2020
[[SDImageCodersManager sharedManager] addCoder:SVGCoder];
21-
NSURL *SVGURL = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/1/14/Mahuri.svg"];
22-
NSURL *SVGURL2 = [NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/6/67/Firefox_Logo%2C_2017.svg"];
21+
NSURL *svgURL = [NSURL URLWithString:@"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/w3c.svg"];
22+
NSURL *svgURL2 = [NSURL URLWithString:@"https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/wikimedia.svg"];
2323

2424
CGSize screenSize = self.view.bounds.size;
2525

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

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

3234
[self.view addSubview:imageView1];
3335
[self.view addSubview:imageView2];
3436

35-
[imageView1 sd_setImageWithURL:SVGURL placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
37+
[imageView1 sd_setImageWithURL:svgURL placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
3638
if (image) {
3739
NSLog(@"SVG load success");
3840
NSData *svgData = [image sd_imageDataAsFormat:SDImageFormatSVG];
3941
NSAssert(svgData.length > 0, @"SVG Data should exist");
4042
}
4143
}];
42-
[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) {
44+
[imageView2 sd_setImageWithURL:svgURL2 placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
4345
if (image) {
4446
NSLog(@"SVG load animation success");
4547
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {

Example/SDWebImageSVGCoder.xcodeproj/project.pbxproj

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,13 @@
429429
);
430430
inputPaths = (
431431
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSVGCoder_Example/Pods-SDWebImageSVGCoder_Example-frameworks.sh",
432-
"${BUILT_PRODUCTS_DIR}/CocoaLumberjack-iOS/CocoaLumberjack.framework",
433432
"${BUILT_PRODUCTS_DIR}/SDWebImage-iOS/SDWebImage.framework",
434433
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-iOS/SDWebImageSVGCoder.framework",
435-
"${BUILT_PRODUCTS_DIR}/SVGKit-iOS/SVGKit.framework",
436434
);
437435
name = "[CP] Embed Pods Frameworks";
438436
outputPaths = (
439-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaLumberjack.framework",
440437
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
441438
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
442-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVGKit.framework",
443439
);
444440
runOnlyForDeploymentPostprocessing = 0;
445441
shellPath = /bin/sh;
@@ -451,23 +447,15 @@
451447
buildActionMask = 2147483647;
452448
files = (
453449
);
454-
inputFileListPaths = (
455-
);
456450
inputPaths = (
457451
"${PODS_ROOT}/Target Support Files/Pods-SDWebImageSVGCoder_Example macOS/Pods-SDWebImageSVGCoder_Example macOS-frameworks.sh",
458-
"${BUILT_PRODUCTS_DIR}/CocoaLumberjack-macOS/CocoaLumberjack.framework",
459452
"${BUILT_PRODUCTS_DIR}/SDWebImage-macOS/SDWebImage.framework",
460453
"${BUILT_PRODUCTS_DIR}/SDWebImageSVGCoder-macOS/SDWebImageSVGCoder.framework",
461-
"${BUILT_PRODUCTS_DIR}/SVGKit-macOS/SVGKit.framework",
462454
);
463455
name = "[CP] Embed Pods Frameworks";
464-
outputFileListPaths = (
465-
);
466456
outputPaths = (
467-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CocoaLumberjack.framework",
468457
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
469458
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImageSVGCoder.framework",
470-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SVGKit.framework",
471459
);
472460
runOnlyForDeploymentPostprocessing = 0;
473461
shellPath = /bin/sh;

Example/SDWebImageSVGCoder.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
<dict>
55
<key>BuildSystemType</key>
66
<string>Original</string>
7+
<key>PreviewsEnabled</key>
8+
<false/>
79
</dict>
810
</plist>

Example/SDWebImageSVGCoder/SDViewController.m

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import "SDViewController.h"
1010
#import <SDWebImageSVGCoder/SDWebImageSVGCoder.h>
11-
#import <SVGKit/SVGKit.h>
1211

1312
@interface SDViewController ()
1413

@@ -23,26 +22,22 @@ - (void)viewDidLoad
2322

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

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

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

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

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

4742
[self.view addSubview:imageView1];
4843
[self.view addSubview:imageView2];
@@ -60,10 +55,16 @@ - (void)viewDidLoad
6055
NSLog(@"SVGKFastImageView SVG load success");
6156
}
6257
}];
63-
// For `UIImageView`, you can specify a desired SVG size instead of original SVG viewport (which may be small)
64-
[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) {
58+
[imageView3 sd_setImageWithURL:svgURL3 placeholderImage:nil options:SDWebImageRetryFailed context:nil progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
6559
if (image) {
66-
NSLog(@"UIImageView SVG load success");
60+
NSLog(@"SVG load animation success");
61+
[UIView animateWithDuration:2 animations:^{
62+
imageView3.bounds = CGRectMake(0, 0, 300, 300);
63+
} completion:^(BOOL finished) {
64+
[UIView animateWithDuration:2 animations:^{
65+
imageView3.bounds = CGRectMake(0, 0, 100, 100);
66+
}];
67+
}];
6768
}
6869
}];
6970
}

0 commit comments

Comments
 (0)