Merge pull request #1085 from flovilmart/AppExtensionSafe
Determines at runtime is UIApplication is available as per #1082
This commit is contained in:
commit
91b4251115
|
@ -1095,6 +1095,7 @@
|
||||||
4A2CAE131AB4BB5400B6BC39 /* Debug */ = {
|
4A2CAE131AB4BB5400B6BC39 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
@ -1141,6 +1142,7 @@
|
||||||
4A2CAE141AB4BB5400B6BC39 /* Release */ = {
|
4A2CAE141AB4BB5400B6BC39 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
@ -1232,6 +1234,7 @@
|
||||||
53761323155AD0D5005750A4 /* Debug */ = {
|
53761323155AD0D5005750A4 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
APPLICATION_EXTENSION_API_ONLY = NO;
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEAD_CODE_STRIPPING = NO;
|
DEAD_CODE_STRIPPING = NO;
|
||||||
|
@ -1255,6 +1258,7 @@
|
||||||
53761324155AD0D5005750A4 /* Release */ = {
|
53761324155AD0D5005750A4 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
|
APPLICATION_EXTENSION_API_ONLY = NO;
|
||||||
CLANG_ENABLE_OBJC_ARC = YES;
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEAD_CODE_STRIPPING = NO;
|
DEAD_CODE_STRIPPING = NO;
|
||||||
|
|
|
@ -20,20 +20,6 @@
|
||||||
ReferencedContainer = "container:SDWebImage.xcodeproj">
|
ReferencedContainer = "container:SDWebImage.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildActionEntry>
|
</BuildActionEntry>
|
||||||
<BuildActionEntry
|
|
||||||
buildForTesting = "YES"
|
|
||||||
buildForRunning = "YES"
|
|
||||||
buildForProfiling = "NO"
|
|
||||||
buildForArchiving = "NO"
|
|
||||||
buildForAnalyzing = "YES">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "4A2CAE081AB4BB5400B6BC39"
|
|
||||||
BuildableName = "WebImageTests.xctest"
|
|
||||||
BlueprintName = "WebImageTests"
|
|
||||||
ReferencedContainer = "container:SDWebImage.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</BuildActionEntry>
|
|
||||||
</BuildActionEntries>
|
</BuildActionEntries>
|
||||||
</BuildAction>
|
</BuildAction>
|
||||||
<TestAction
|
<TestAction
|
||||||
|
@ -42,26 +28,7 @@
|
||||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
buildConfiguration = "Debug">
|
buildConfiguration = "Debug">
|
||||||
<Testables>
|
<Testables>
|
||||||
<TestableReference
|
|
||||||
skipped = "NO">
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "4A2CAE081AB4BB5400B6BC39"
|
|
||||||
BuildableName = "WebImageTests.xctest"
|
|
||||||
BlueprintName = "WebImageTests"
|
|
||||||
ReferencedContainer = "container:SDWebImage.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</TestableReference>
|
|
||||||
</Testables>
|
</Testables>
|
||||||
<MacroExpansion>
|
|
||||||
<BuildableReference
|
|
||||||
BuildableIdentifier = "primary"
|
|
||||||
BlueprintIdentifier = "4A2CADFE1AB4BB5300B6BC39"
|
|
||||||
BuildableName = "WebImage.framework"
|
|
||||||
BlueprintName = "WebImage"
|
|
||||||
ReferencedContainer = "container:SDWebImage.xcodeproj">
|
|
||||||
</BuildableReference>
|
|
||||||
</MacroExpansion>
|
|
||||||
</TestAction>
|
</TestAction>
|
||||||
<LaunchAction
|
<LaunchAction
|
||||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
|
|
@ -516,7 +516,11 @@ FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)backgroundCleanDisk {
|
- (void)backgroundCleanDisk {
|
||||||
UIApplication *application = [UIApplication sharedApplication];
|
Class UIApplicationClass = NSClassFromString(@"UIApplication");
|
||||||
|
if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
|
||||||
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
|
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
|
||||||
// Clean up any unfinished task business by marking where you
|
// Clean up any unfinished task business by marking where you
|
||||||
// stopped or ending the task outright.
|
// stopped or ending the task outright.
|
||||||
|
|
|
@ -74,15 +74,18 @@ NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinis
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
|
#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __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;
|
__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;
|
__strong __typeof (wself) sself = wself;
|
||||||
|
|
||||||
if (sself) {
|
if (sself) {
|
||||||
[sself cancel];
|
[sself cancel];
|
||||||
|
|
||||||
[[UIApplication sharedApplication] endBackgroundTask:sself.backgroundTaskId];
|
[app endBackgroundTask:sself.backgroundTaskId];
|
||||||
sself.backgroundTaskId = UIBackgroundTaskInvalid;
|
sself.backgroundTaskId = UIBackgroundTaskInvalid;
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
@ -126,8 +129,13 @@ NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinis
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
|
#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) {
|
if (self.backgroundTaskId != UIBackgroundTaskInvalid) {
|
||||||
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskId];
|
UIApplication * app = [UIApplication performSelector:@selector(sharedApplication)];
|
||||||
|
[app endBackgroundTask:self.backgroundTaskId];
|
||||||
self.backgroundTaskId = UIBackgroundTaskInvalid;
|
self.backgroundTaskId = UIBackgroundTaskInvalid;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue