diff --git a/SDWebImage.xcodeproj/project.pbxproj b/SDWebImage.xcodeproj/project.pbxproj index c4f20796..4be5483c 100644 --- a/SDWebImage.xcodeproj/project.pbxproj +++ b/SDWebImage.xcodeproj/project.pbxproj @@ -1095,6 +1095,7 @@ 4A2CAE131AB4BB5400B6BC39 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1141,6 +1142,7 @@ 4A2CAE141AB4BB5400B6BC39 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1232,6 +1234,7 @@ 53761323155AD0D5005750A4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; DEAD_CODE_STRIPPING = NO; @@ -1255,6 +1258,7 @@ 53761324155AD0D5005750A4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; DEAD_CODE_STRIPPING = NO; diff --git a/SDWebImage.xcworkspace/xcshareddata/xcschemes/WebImage.xcscheme b/SDWebImage.xcworkspace/xcshareddata/xcschemes/WebImage.xcscheme index eff4eec2..20121756 100644 --- a/SDWebImage.xcworkspace/xcshareddata/xcschemes/WebImage.xcscheme +++ b/SDWebImage.xcworkspace/xcshareddata/xcschemes/WebImage.xcscheme @@ -20,20 +20,6 @@ ReferencedContainer = "container:SDWebImage.xcodeproj"> - - - - - - - - - - - - = __IPHONE_4_0 - if ([self shouldContinueWhenAppEntersBackground]) { + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + BOOL hasApplication = UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)]; + if (hasApplication && [self shouldContinueWhenAppEntersBackground]) { __weak __typeof__ (self) wself = self; - self.backgroundTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ + UIApplication * app = [UIApplicationClass performSelector:@selector(sharedApplication)]; + self.backgroundTaskId = [app beginBackgroundTaskWithExpirationHandler:^{ __strong __typeof (wself) sself = wself; if (sself) { [sself cancel]; - [[UIApplication sharedApplication] endBackgroundTask:sself.backgroundTaskId]; + [app endBackgroundTask:sself.backgroundTaskId]; sself.backgroundTaskId = UIBackgroundTaskInvalid; } }]; @@ -126,8 +129,13 @@ NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinis } #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { + return; + } if (self.backgroundTaskId != UIBackgroundTaskInvalid) { - [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskId]; + UIApplication * app = [UIApplication performSelector:@selector(sharedApplication)]; + [app endBackgroundTask:self.backgroundTaskId]; self.backgroundTaskId = UIBackgroundTaskInvalid; } #endif