From 81f72b8215c76a5e393fcc84cc93b4138c4d32ff Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 1 Dec 2019 17:54:24 +0800 Subject: [PATCH 1/2] Changing the PDF symbol naming with the encoded string instead, workaround for App Store submit --- SDWebImagePDFCoder/Classes/SDImagePDFCoder.m | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m b/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m index 9921930..a4231cc 100644 --- a/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m +++ b/SDWebImagePDFCoder/Classes/SDImagePDFCoder.m @@ -12,20 +12,27 @@ #define SD_FOUR_CC(c1,c2,c3,c4) ((uint32_t)(((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1))) #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) +static SEL SDImageWithCGPDFPageSEL = NULL; +static SEL SDCGPDFPageSEL = NULL; -- (instancetype)_initWithCGPDFPage:(CGPDFPageRef)page; -- (instancetype)_initWithCGPDFPage:(CGPDFPageRef)page scale:(double)scale orientation:(UIImageOrientation)orientation; -+ (instancetype)_imageWithCGPDFPage:(CGPDFPageRef)page; -+ (instancetype)_imageWithCGPDFPage:(CGPDFPageRef)page scale:(double)scale orientation:(UIImageOrientation)orientation; -- (CGPDFPageRef)_CGPDFPage; - -@end +static inline NSString *SDBase64DecodedString(NSString *base64String) { + NSData *data = [[NSData alloc] initWithBase64EncodedString:base64String options:NSDataBase64DecodingIgnoreUnknownCharacters]; + if (!data) { + return nil; + } + return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; +} #endif @implementation SDImagePDFCoder +#if SD_UIKIT || SD_WATCH ++ (void)initialize { + SDImageWithCGPDFPageSEL = NSSelectorFromString(SDBase64DecodedString(@"X2ltYWdlV2l0aENHUERGUGFnZTo=")); + SDCGPDFPageSEL = NSSelectorFromString(SDBase64DecodedString(@"X0NHUERGUGFnZQ==")); +} +#endif + + (SDImagePDFCoder *)sharedCoder { static dispatch_once_t onceToken; static SDImagePDFCoder *coder; @@ -98,7 +105,7 @@ - (NSData *)encodedDataWithImage:(UIImage *)image format:(SDImageFormat)format o } return ((NSPDFImageRep *)imageRep).PDFRepresentation; #else - CGPDFPageRef page = [image _CGPDFPage]; + CGPDFPageRef page = ((CGPDFPageRef (*)(id,SEL))[image methodForSelector:SDCGPDFPageSEL])(image, SDCGPDFPageSEL); if (!page) { return nil; } @@ -154,7 +161,7 @@ - (UIImage *)createVectorPDFWithData:(nonnull NSData *)data pageNumber:(NSUInteg return nil; } - image = [UIImage _imageWithCGPDFPage:page]; + image = ((UIImage *(*)(id,SEL,CGPDFPageRef))[UIImage.class methodForSelector:SDImageWithCGPDFPageSEL])(UIImage.class, SDImageWithCGPDFPageSEL, page); CGPDFDocumentRelease(document); #endif @@ -231,7 +238,7 @@ + (BOOL)supportsVectorPDFImage { static BOOL supports; dispatch_once(&onceToken, ^{ // iOS 11+ supports PDF built-in rendering, use selector to check is more accurate - if ([UIImage respondsToSelector:@selector(_imageWithCGPDFPage:)]) { + if ([UIImage respondsToSelector:SDImageWithCGPDFPageSEL]) { supports = YES; } else { supports = NO; From c03c1cc8f702578f5dc7c1fae2da2ede421b1074 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 1 Dec 2019 17:56:22 +0800 Subject: [PATCH 2/2] Add git ignore to filter the Podfile.lock --- .gitignore | 1 + Example/Podfile.lock | 25 ------------------- .../project.pbxproj | 8 ------ .../xcshareddata/WorkspaceSettings.xcsettings | 8 ------ 4 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 Example/Podfile.lock delete mode 100644 Example/SDWebImagePDFCoder.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings diff --git a/.gitignore b/.gitignore index 8b14304..301c8a7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ Carthage/Build # `pod install` in .travis.yml # Pods/ +Podfile.lock # SwiftPM .swiftpm diff --git a/Example/Podfile.lock b/Example/Podfile.lock deleted file mode 100644 index e356f36..0000000 --- a/Example/Podfile.lock +++ /dev/null @@ -1,25 +0,0 @@ -PODS: - - SDWebImage (5.0.2): - - SDWebImage/Core (= 5.0.2) - - SDWebImage/Core (5.0.2) - - SDWebImagePDFCoder (0.2.0): - - SDWebImage (~> 5.0) - -DEPENDENCIES: - - SDWebImagePDFCoder (from `../`) - -SPEC REPOS: - https://github.com/cocoapods/specs.git: - - SDWebImage - -EXTERNAL SOURCES: - SDWebImagePDFCoder: - :path: "../" - -SPEC CHECKSUMS: - SDWebImage: 6764b5fa0f73c203728052955dbefa2bf1f33282 - SDWebImagePDFCoder: e980f143f97ff0bf8366a4b74d0acb50f0c9d8b6 - -PODFILE CHECKSUM: 13cc95bf609e99946808ed65a198e32a645f3acd - -COCOAPODS: 1.6.1 diff --git a/Example/SDWebImagePDFCoder.xcodeproj/project.pbxproj b/Example/SDWebImagePDFCoder.xcodeproj/project.pbxproj index 1ebf164..feaaf48 100644 --- a/Example/SDWebImagePDFCoder.xcodeproj/project.pbxproj +++ b/Example/SDWebImagePDFCoder.xcodeproj/project.pbxproj @@ -386,16 +386,12 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-SDWebImagePDFCoder_Example macOS/Pods-SDWebImagePDFCoder_Example macOS-frameworks.sh", "${BUILT_PRODUCTS_DIR}/SDWebImage-macOS/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/SDWebImagePDFCoder-macOS/SDWebImagePDFCoder.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImagePDFCoder.framework", @@ -410,16 +406,12 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-SDWebImagePDFCoder_Example/Pods-SDWebImagePDFCoder_Example-frameworks.sh", "${BUILT_PRODUCTS_DIR}/SDWebImage-iOS/SDWebImage.framework", "${BUILT_PRODUCTS_DIR}/SDWebImagePDFCoder-iOS/SDWebImagePDFCoder.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImagePDFCoder.framework", diff --git a/Example/SDWebImagePDFCoder.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/Example/SDWebImagePDFCoder.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 949b678..0000000 --- a/Example/SDWebImagePDFCoder.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - BuildSystemType - Original - -