Skip to content

Commit 66e08c9

Browse files
committed
Add macOS support by using upstream SVGKit mac port
1 parent 734e888 commit 66e08c9

File tree

14 files changed

+295
-13
lines changed

14 files changed

+295
-13
lines changed

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "rs/SDWebImage" >= 5.0.0-beta3
1+
github "SDWebImage/SDWebImage" >= 5.0.0-beta3
22
github "SVGKit/SVGKit" "2.x"

Cartfile.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
github "CocoaLumberjack/CocoaLumberjack" "3.4.2"
2-
github "SVGKit/SVGKit" "6b673b7ae452e481593047251a61e061bd0aa5a9"
3-
github "rs/SDWebImage" "5.0.0-beta3"
2+
github "SDWebImage/SDWebImage" "5.0.0-beta3"
3+
github "SVGKit/SVGKit" "b1eae9cf1b1dbf69bc15334f905f5c602f1b13ca"

Example/Podfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ EXTERNAL SOURCES:
3030

3131
CHECKOUT OPTIONS:
3232
SVGKit:
33-
:commit: 733acf66e44a02396efc8a6f445d190af592d544
33+
:commit: b1eae9cf1b1dbf69bc15334f905f5c602f1b13ca
3434
:git: https://github.com/SVGKit/SVGKit.git
3535

3636
SPEC CHECKSUMS:
3737
CocoaLumberjack: db7cc9e464771f12054c22ff6947c5a58d43a0fd
3838
SDWebImage: e52654ceef9fdc19f4c612d64a5b6d3f05dd81a4
39-
SDWebImageSVGCoder: f2b3b74ff39acbb28f60c1dad2e0fd19fa04cb6c
40-
SVGKit: 4055d9e809b5db8633755979cfb3b02dc5a8c20d
39+
SDWebImageSVGCoder: a39ffaef7618b138d18eef8e3c49c96a3637fbe2
40+
SVGKit: e0b3dd403cc7cf0d66889f32b6aa1a6b38aa6911
4141

4242
PODFILE CHECKSUM: dc5153f27ba2a6dd43c49d8e0100b34b78f46730
4343

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ You can modify the code or use some other SVG files to check the compatibility.
2020

2121
+ iOS 8
2222
+ tvOS 9
23+
+ macOS 10.10
2324

2425
## Installation
2526

SDWebImageSVGCoder.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ TODO: Add long description of the pod here.
2828

2929
s.ios.deployment_target = '8.0'
3030
s.tvos.deployment_target = '9.0'
31+
s.osx.deployment_target = '10.10'
3132

3233
s.source_files = 'SDWebImageSVGCoder/Classes/**/*', 'SDWebImageSVGCoder/Module/SDWebImageSVGCoder.h'
3334
s.module_map = 'SDWebImageSVGCoder/Module/SDWebImageSVGCoder.modulemap'

SDWebImageSVGCoder.xcodeproj/project.pbxproj

Lines changed: 181 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1000"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "328C14B52184C856006B0C4A"
18+
BuildableName = "SDWebImageSVGCoder_macOS.framework"
19+
BlueprintName = "SDWebImageSVGCoder macOS"
20+
ReferencedContainer = "container:SDWebImageSVGCoder.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<AdditionalOptions>
33+
</AdditionalOptions>
34+
</TestAction>
35+
<LaunchAction
36+
buildConfiguration = "Debug"
37+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
38+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
39+
launchStyle = "0"
40+
useCustomWorkingDirectory = "NO"
41+
ignoresPersistentStateOnLaunch = "NO"
42+
debugDocumentVersioning = "YES"
43+
debugServiceExtension = "internal"
44+
allowLocationSimulation = "YES">
45+
<MacroExpansion>
46+
<BuildableReference
47+
BuildableIdentifier = "primary"
48+
BlueprintIdentifier = "328C14B52184C856006B0C4A"
49+
BuildableName = "SDWebImageSVGCoder_macOS.framework"
50+
BlueprintName = "SDWebImageSVGCoder macOS"
51+
ReferencedContainer = "container:SDWebImageSVGCoder.xcodeproj">
52+
</BuildableReference>
53+
</MacroExpansion>
54+
<AdditionalOptions>
55+
</AdditionalOptions>
56+
</LaunchAction>
57+
<ProfileAction
58+
buildConfiguration = "Release"
59+
shouldUseLaunchSchemeArgsEnv = "YES"
60+
savedToolIdentifier = ""
61+
useCustomWorkingDirectory = "NO"
62+
debugDocumentVersioning = "YES">
63+
<MacroExpansion>
64+
<BuildableReference
65+
BuildableIdentifier = "primary"
66+
BlueprintIdentifier = "328C14B52184C856006B0C4A"
67+
BuildableName = "SDWebImageSVGCoder_macOS.framework"
68+
BlueprintName = "SDWebImageSVGCoder macOS"
69+
ReferencedContainer = "container:SDWebImageSVGCoder.xcodeproj">
70+
</BuildableReference>
71+
</MacroExpansion>
72+
</ProfileAction>
73+
<AnalyzeAction
74+
buildConfiguration = "Debug">
75+
</AnalyzeAction>
76+
<ArchiveAction
77+
buildConfiguration = "Release"
78+
revealArchiveInOrganizer = "YES">
79+
</ArchiveAction>
80+
</Scheme>

SDWebImageSVGCoder/Classes/SDImageSVGCoder.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ - (UIImage *)decodedImageWithData:(NSData *)data options:(SDImageCoderOptions *)
4141
// Check specified image size
4242
SDWebImageContext *context = options[SDImageCoderWebImageContext];
4343
if (context[SDWebImageContextVectorImageSize]) {
44-
CGSize imageSize = [context[SDWebImageContextVectorImageSize] CGSizeValue];
44+
NSValue *sizeValue = context[SDWebImageContextVectorImageSize];
45+
#if SD_UIKIT
46+
CGSize imageSize = sizeValue.CGSizeValue;
47+
#else
48+
CGSize imageSize = sizeValue.sizeValue;
49+
#endif
4550
if (!CGSizeEqualToSize(imageSize, CGSizeZero)) {
4651
svgImage.size = imageSize;
4752
}

SDWebImageSVGCoder/Classes/SDSVGImage.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ @implementation SDSVGImage
1919
- (instancetype)initWithSVGImage:(SVGKImage *)image {
2020
NSParameterAssert(image);
2121
UIImage *posterImage = image.UIImage;
22-
self = [super initWithCGImage:posterImage.CGImage scale:posterImage.scale orientation:posterImage.imageOrientation];
22+
#if SD_UIKIT
23+
UIImageOrientation imageOrientation = posterImage.imageOrientation;
24+
#else
25+
CGImagePropertyOrientation imageOrientation = kCGImagePropertyOrientationUp;
26+
#endif
27+
self = [super initWithCGImage:posterImage.CGImage scale:posterImage.scale orientation:imageOrientation];
2328
if (self) {
2429
self.SVGImage = image;
2530
}
@@ -59,7 +64,12 @@ - (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale options:(SDImag
5964
// Check specified image size
6065
SDWebImageContext *context = options[SDImageCoderWebImageContext];
6166
if (context[SDWebImageContextVectorImageSize]) {
62-
CGSize imageSize = [context[SDWebImageContextVectorImageSize] CGSizeValue];
67+
NSValue *sizeValue = context[SDWebImageContextVectorImageSize];
68+
#if SD_UIKIT
69+
CGSize imageSize = sizeValue.CGSizeValue;
70+
#else
71+
CGSize imageSize = sizeValue.sizeValue;
72+
#endif
6373
if (!CGSizeEqualToSize(imageSize, CGSizeZero)) {
6474
svgImage.size = imageSize;
6575
}

SDWebImageSVGCoder/Classes/SDWebImageSVGCoderDefine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
@class SVGKImage;
1111

12+
#if SD_UIKIT
1213
/**
1314
Adjust `SVGKImage`'s viewPort && viewBox to match the specify `contentMode` of view size.
1415
@note Though this util method can be used outside this framework. For simple SVG image loading, it's recommaned to use `sd_adjustContentMode` property on `SVGKImageView+WebCache`.
@@ -18,6 +19,7 @@
1819
@param viewSize Target view size, typically specify the `view.bounds.size`.
1920
*/
2021
FOUNDATION_EXPORT void SDAdjustSVGContentMode(SVGKImage * __nonnull svgImage, UIViewContentMode contentMode, CGSize viewSize);
22+
#endif
2123

2224
/**
2325
A CGSize raw value which specify the desired vector image size during image loading. Because vector image like SVG format, may not contains a fixed size, or you want to get a larger size bitmap representation UIImage. (NSValue)

0 commit comments

Comments
 (0)