Skip to content

Commit 3ac71ca

Browse files
committed
Fix the macOS build issue for SVG
1 parent 35839c9 commit 3ac71ca

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

SDWebImageSVGCoder/Classes/SDImageSVGCoder.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
static CGSVGDocumentRef (*CGSVGDocumentRetain)(CGSVGDocumentRef);
1919
static void (*CGSVGDocumentRelease)(CGSVGDocumentRef);
2020

21+
#if SD_UIKIT
22+
2123
@interface UIImage (PrivateSVGSupport)
2224

2325
- (instancetype)_initWithCGSVGDocument:(CGSVGDocumentRef)document;
@@ -28,6 +30,8 @@ - (CGSVGDocumentRef)_CGSVGDocument;
2830

2931
@end
3032

33+
#endif
34+
3135
@implementation SDImageSVGCoder
3236

3337
+ (SDImageSVGCoder *)sharedCoder {
@@ -55,14 +59,18 @@ - (UIImage *)decodedImageWithData:(NSData *)data options:(SDImageCoderOptions *)
5559
if (!data) {
5660
return nil;
5761
}
58-
62+
#if SD_UIKIT
5963
if ([self.class supportsVectorSVGImage]) {
6064
return [self createVectorSVGWithData:data options:options];
6165
} else {
6266
return [self createBitmapSVGWithData:data options:options];
6367
}
68+
#else
69+
return [self createBitmapSVGWithData:data options:options];
70+
#endif
6471
}
6572

73+
#if SD_UIKIT
6674
- (UIImage *)createVectorSVGWithData:(NSData *)data options:(SDImageCoderOptions *)options {
6775
NSParameterAssert(data);
6876
CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
@@ -78,6 +86,7 @@ - (UIImage *)createVectorSVGWithData:(NSData *)data options:(SDImageCoderOptions
7886

7987
return image;
8088
}
89+
#endif
8190

8291
- (UIImage *)createBitmapSVGWithData:(NSData *)data options:(SDImageCoderOptions *)options {
8392
NSParameterAssert(data);
@@ -148,6 +157,9 @@ - (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format o
148157
#pragma mark - Helper
149158

150159
+ (BOOL)supportsVectorSVGImage {
160+
#if SD_MAC
161+
return NO;
162+
#else
151163
static dispatch_once_t onceToken;
152164
static BOOL supports;
153165
dispatch_once(&onceToken, ^{
@@ -159,6 +171,7 @@ + (BOOL)supportsVectorSVGImage {
159171
}
160172
});
161173
return supports;
174+
#endif
162175
}
163176

164177
+ (BOOL)isSVGFormatForData:(NSData *)data {

0 commit comments

Comments
 (0)