diff --git a/Example/Podfile b/Example/Podfile index 5889aca8..8ef66197 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -2,6 +2,10 @@ target 'TUSKit' do pod "TUSKit", :path => "../" end +target 'TUSKit_MacOS_Example' do + pod "TUSKit", :path => "../" +end + target 'Tests' do pod "TUSKit", :path => "../" diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 61773139..ccfdcf9e 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - TUSKit (1.3.5) + - TUSKit (1.3.8) DEPENDENCIES: - TUSKit (from `../`) @@ -9,8 +9,8 @@ EXTERNAL SOURCES: :path: ../ SPEC CHECKSUMS: - TUSKit: fb50aa6e1e6d25b2dbe6b07863d8b01acfee5656 + TUSKit: 9cca52b50b17ba92a166203c4f5e609c670a95ff -PODFILE CHECKSUM: f328d9ebaab951bf22e19ac2e19a7342567c45f8 +PODFILE CHECKSUM: 92550622848fc22aa648e69bd203ffac3b5d32b2 COCOAPODS: 1.2.1 diff --git a/Example/TUSKit MacOS Example/ViewController.m b/Example/TUSKit MacOS Example/ViewController.m index 09bd8396..10131a82 100644 --- a/Example/TUSKit MacOS Example/ViewController.m +++ b/Example/TUSKit MacOS Example/ViewController.m @@ -7,6 +7,7 @@ // #import "ViewController.h" +#import @implementation ViewController diff --git a/Example/TUSKit.xcodeproj/project.pbxproj b/Example/TUSKit.xcodeproj/project.pbxproj index 3549f804..b0c1ff8d 100644 --- a/Example/TUSKit.xcodeproj/project.pbxproj +++ b/Example/TUSKit.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; 6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; }; 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; + 696B4FBCDC39DC19AC059E57 /* libPods-TUSKit_MacOS_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B2585C78D79329E8BD58CB2F /* libPods-TUSKit_MacOS_Example.a */; }; 81A8CED36936361B31D51697 /* libPods-TUSKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94BE9E2097B840319C7576AD /* libPods-TUSKit.a */; }; /* End PBXBuildFile section */ @@ -59,7 +60,7 @@ /* Begin PBXFileReference section */ 2198F7C3EFA4406DB60E9FD0 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; - 28C00B041ECD79F600430748 /* TUSKit MacOS Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "TUSKit MacOS Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 28C00B041ECD79F600430748 /* TUSKit_MacOS_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TUSKit_MacOS_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 28C00B061ECD79F600430748 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 28C00B071ECD79F600430748 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 28C00B0A1ECD79F600430748 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -98,10 +99,13 @@ 6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; 606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = ""; }; 94BE9E2097B840319C7576AD /* libPods-TUSKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TUSKit.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 97BA7FEA7A277EE9173FC532 /* Pods-TUSKit_MacOS_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TUSKit_MacOS_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-TUSKit_MacOS_Example/Pods-TUSKit_MacOS_Example.release.xcconfig"; sourceTree = ""; }; B154447F00BA422485024C03 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; B156087D9854F9F535819A05 /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = ""; }; + B2585C78D79329E8BD58CB2F /* libPods-TUSKit_MacOS_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TUSKit_MacOS_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; E4D528B07F809226971E7E48 /* Pods-TUSKit.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TUSKit.release.xcconfig"; path = "Pods/Target Support Files/Pods-TUSKit/Pods-TUSKit.release.xcconfig"; sourceTree = ""; }; F4DC08B04A13457D8409F9B4 /* TUSKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TUSKit.podspec; path = ../TUSKit.podspec; sourceTree = ""; }; + FC5575320A03013A99909793 /* Pods-TUSKit_MacOS_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TUSKit_MacOS_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TUSKit_MacOS_Example/Pods-TUSKit_MacOS_Example.debug.xcconfig"; sourceTree = ""; }; FF8166735401D785C86DF9B4 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -110,6 +114,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 696B4FBCDC39DC19AC059E57 /* libPods-TUSKit_MacOS_Example.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -159,6 +164,8 @@ E4D528B07F809226971E7E48 /* Pods-TUSKit.release.xcconfig */, 544ABCA6686C6597A4CA55C6 /* Pods-Tests.debug.xcconfig */, B156087D9854F9F535819A05 /* Pods-Tests.release.xcconfig */, + FC5575320A03013A99909793 /* Pods-TUSKit_MacOS_Example.debug.xcconfig */, + 97BA7FEA7A277EE9173FC532 /* Pods-TUSKit_MacOS_Example.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -224,7 +231,7 @@ children = ( 6003F58A195388D20070C39A /* TUSKit.app */, 6003F5AE195388D20070C39A /* Tests.xctest */, - 28C00B041ECD79F600430748 /* TUSKit MacOS Example.app */, + 28C00B041ECD79F600430748 /* TUSKit_MacOS_Example.app */, 28C00B191ECD79F600430748 /* TUSKit MacOS ExampleTests.xctest */, 28C00B241ECD79F600430748 /* TUSKit MacOS ExampleUITests.xctest */, ); @@ -240,6 +247,7 @@ 6003F5AF195388D20070C39A /* XCTest.framework */, 94BE9E2097B840319C7576AD /* libPods-TUSKit.a */, FF8166735401D785C86DF9B4 /* libPods-Tests.a */, + B2585C78D79329E8BD58CB2F /* libPods-TUSKit_MacOS_Example.a */, ); name = Frameworks; sourceTree = ""; @@ -302,21 +310,24 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 28C00B031ECD79F600430748 /* TUSKit MacOS Example */ = { + 28C00B031ECD79F600430748 /* TUSKit_MacOS_Example */ = { isa = PBXNativeTarget; - buildConfigurationList = 28C00B311ECD79F600430748 /* Build configuration list for PBXNativeTarget "TUSKit MacOS Example" */; + buildConfigurationList = 28C00B311ECD79F600430748 /* Build configuration list for PBXNativeTarget "TUSKit_MacOS_Example" */; buildPhases = ( + 156793661E95BA435822EAEB /* [CP] Check Pods Manifest.lock */, 28C00B001ECD79F600430748 /* Sources */, 28C00B011ECD79F600430748 /* Frameworks */, 28C00B021ECD79F600430748 /* Resources */, + 3508852BA91B7E96485DD5C7 /* [CP] Embed Pods Frameworks */, + D826D3F1084F37062B809103 /* [CP] Copy Pods Resources */, ); buildRules = ( ); dependencies = ( ); - name = "TUSKit MacOS Example"; + name = TUSKit_MacOS_Example; productName = "TUSKit MacOS Example"; - productReference = 28C00B041ECD79F600430748 /* TUSKit MacOS Example.app */; + productReference = 28C00B041ECD79F600430748 /* TUSKit_MacOS_Example.app */; productType = "com.apple.product-type.application"; }; 28C00B181ECD79F600430748 /* TUSKit MacOS ExampleTests */ = { @@ -446,7 +457,7 @@ targets = ( 6003F589195388D20070C39A /* TUSKit */, 6003F5AD195388D20070C39A /* Tests */, - 28C00B031ECD79F600430748 /* TUSKit MacOS Example */, + 28C00B031ECD79F600430748 /* TUSKit_MacOS_Example */, 28C00B181ECD79F600430748 /* TUSKit MacOS ExampleTests */, 28C00B231ECD79F600430748 /* TUSKit MacOS ExampleUITests */, ); @@ -499,6 +510,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 156793661E95BA435822EAEB /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; 2C36823982C5A11655A46F3E /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -514,6 +540,21 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests/Pods-Tests-resources.sh\"\n"; showEnvVarsInLog = 0; }; + 3508852BA91B7E96485DD5C7 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TUSKit_MacOS_Example/Pods-TUSKit_MacOS_Example-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 84022079743DAE094D266266 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -574,6 +615,21 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TUSKit/Pods-TUSKit-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + D826D3F1084F37062B809103 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TUSKit_MacOS_Example/Pods-TUSKit_MacOS_Example-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; DB0D5A03BA12C8E5F1B6AEAD /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -641,12 +697,12 @@ /* Begin PBXTargetDependency section */ 28C00B1B1ECD79F600430748 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 28C00B031ECD79F600430748 /* TUSKit MacOS Example */; + target = 28C00B031ECD79F600430748 /* TUSKit_MacOS_Example */; targetProxy = 28C00B1A1ECD79F600430748 /* PBXContainerItemProxy */; }; 28C00B261ECD79F600430748 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = 28C00B031ECD79F600430748 /* TUSKit MacOS Example */; + target = 28C00B031ECD79F600430748 /* TUSKit_MacOS_Example */; targetProxy = 28C00B251ECD79F600430748 /* PBXContainerItemProxy */; }; 6003F5B4195388D20070C39A /* PBXTargetDependency */ = { @@ -702,6 +758,7 @@ /* Begin XCBuildConfiguration section */ 28C00B2B1ECD79F600430748 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = FC5575320A03013A99909793 /* Pods-TUSKit_MacOS_Example.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_NONNULL = YES; @@ -729,6 +786,7 @@ }; 28C00B2C1ECD79F600430748 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 97BA7FEA7A277EE9173FC532 /* Pods-TUSKit_MacOS_Example.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_NONNULL = YES; @@ -1015,13 +1073,14 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 28C00B311ECD79F600430748 /* Build configuration list for PBXNativeTarget "TUSKit MacOS Example" */ = { + 28C00B311ECD79F600430748 /* Build configuration list for PBXNativeTarget "TUSKit_MacOS_Example" */ = { isa = XCConfigurationList; buildConfigurations = ( 28C00B2B1ECD79F600430748 /* Debug */, 28C00B2C1ECD79F600430748 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 28C00B321ECD79F600430748 /* Build configuration list for PBXNativeTarget "TUSKit MacOS ExampleTests" */ = { isa = XCConfigurationList; @@ -1030,6 +1089,7 @@ 28C00B2E1ECD79F600430748 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 28C00B331ECD79F600430748 /* Build configuration list for PBXNativeTarget "TUSKit MacOS ExampleUITests" */ = { isa = XCConfigurationList; @@ -1038,6 +1098,7 @@ 28C00B301ECD79F600430748 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 6003F585195388D10070C39A /* Build configuration list for PBXProject "TUSKit" */ = { isa = XCConfigurationList; diff --git a/Pod/Classes/TUSAssetData.h b/Pod/Classes/TUSAssetData.h index 9f811973..f920c0bc 100755 --- a/Pod/Classes/TUSAssetData.h +++ b/Pod/Classes/TUSAssetData.h @@ -9,12 +9,22 @@ // Copyright (c) 2015-2016 Mark Robert Masterson. All rights reserved. -#import + #import "TUSData.h" +#if TARGET_OS_IPHONE +#import +#elif TARGET_OS_MAC +@import MediaLibrary; +#endif + @interface TUSAssetData : TUSData +#if TARGET_OS_IPHONE - (id)initWithAsset:(ALAsset*)asset; +#elif TARGET_OS_MAC +- (id)initWithAsset:(MLMediaObject*)asset; +#endif @end diff --git a/Pod/Classes/TUSAssetData.m b/Pod/Classes/TUSAssetData.m index 27c10096..edbfe7a5 100755 --- a/Pod/Classes/TUSAssetData.m +++ b/Pod/Classes/TUSAssetData.m @@ -12,11 +12,16 @@ #import "TUSAssetData.h" @interface TUSAssetData () +#if TARGET_OS_IPHONE @property (strong, nonatomic) ALAsset* asset; +#elif TARGET_OS_MAC +@property (strong, nonatomic) MLMediaObject* asset; +#endif @end @implementation TUSAssetData +#if TARGET_OS_IPHONE - (id)initWithAsset:(ALAsset*)asset { self = [super init]; @@ -25,8 +30,21 @@ - (id)initWithAsset:(ALAsset*)asset } return self; } +#ELIF TARGET_OS_MAC +- (id)initWithAsset:(MLMediaObject*)asset +{ + self = [super init]; + if (self) { + self.asset = asset; + } + return self; +} +#endif + + #pragma mark - TUSData Methods +#if TARGET_OS_IPHONE - (long long)length { ALAssetRepresentation* assetRepresentation = [_asset defaultRepresentation]; @@ -44,7 +62,26 @@ - (long long)length return [assetRepresentation size]; } +#ELIF TARGET_OS_MAC +- (long long)length +{ + if (!_asset) { + // NOTE: + // defaultRepresentation "returns nil for assets from a shared photo + // stream that are not yet available locally." (ALAsset Class Reference) + + // TODO: + // Handle deferred availability of ALAssetRepresentation, + // by registering for an ALAssetsLibraryChangedNotification. + TUSLog(@"@TODO: Implement support for ALAssetsLibraryChangedNotification to support shared photo stream assets"); + return 0; + } + + return [_asset fileSize]; +} +#endif +#if TARGET_OS_IPHONE - (NSUInteger)getBytes:(uint8_t *)buffer fromOffset:(long long)offset length:(NSUInteger)length @@ -56,5 +93,8 @@ - (NSUInteger)getBytes:(uint8_t *)buffer length:length error:error]; } +#ELIF TARGET_OS_MAC +#endif + @end diff --git a/Pod/Classes/TUSResumableUpload.m b/Pod/Classes/TUSResumableUpload.m index 178c9f90..4d3697aa 100755 --- a/Pod/Classes/TUSResumableUpload.m +++ b/Pod/Classes/TUSResumableUpload.m @@ -279,9 +279,13 @@ - (BOOL)createFile [request setAllHTTPHeaderFields:mutableHeader]; __weak TUSResumableUpload * weakself = self; + + #if TARGET_OS_IPHONE UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ [weakself cancel]; - }]; + }]; #elif TARGET_OS_MAC + #endif + self.currentTask = [self.delegate.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error){ if (weakself.currentTask){ // Should only be false if self has been destroyed, but we need to account for that because of the removeTask call. [weakself.delegate removeTask:weakself.currentTask]; @@ -342,7 +346,12 @@ - (BOOL)createFile } weakself.idle = YES; [weakself.delegate saveUpload:weakself]; // Save current state for reloading - only save when we get a call back, not at the start of one (because this is the only time the state changes) - [[UIApplication sharedApplication] endBackgroundTask:bgTask]; + #if TARGET_OS_IPHONE + [[UIApplication sharedApplication] endBackgroundTask:bgTask]; + #elif TARGET_OS_MAC + [weakself cancel]; + #endif + if (delayTime > 0) { __weak NSOperationQueue *weakQueue = [NSOperationQueue currentQueue]; // Delay some time before we try again. We use a weak queue pointer because if the queue goes away, presumably the session has too (the session should have a strong pointer to the queue). @@ -380,9 +389,11 @@ - (BOOL) checkFile [request setAllHTTPHeaderFields:mutableHeader]; __weak TUSResumableUpload * weakself = self; - UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ + #if TARGET_OS_IPHONE + UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ [weakself cancel]; - }]; + }]; + #endif self.currentTask = [self.delegate.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error){ if (weakself.currentTask){ // Should only be false if self has been destroyed, but we need to account for that because of the removeTask call. [weakself.delegate removeTask:weakself.currentTask]; @@ -441,7 +452,11 @@ - (BOOL) checkFile } weakself.idle = YES; [weakself.delegate saveUpload:weakself]; // Save current state for reloading - only save when we get a call back, not at the start of one (because this is the only time the state changes) - [[UIApplication sharedApplication] endBackgroundTask:bgTask]; + #if TARGET_OS_IPHONE + [[UIApplication sharedApplication] endBackgroundTask:bgTask]; + #elif TARGET_OS_MAC + [weakself cancel]; + #endif if (delayTime > 0) { __weak NSOperationQueue *weakQueue = [NSOperationQueue currentQueue]; // Delay some time before we try again. We use a weak queue pointer because if the queue goes away, presumably the session has too (the session should have a strong pointer to the queue). @@ -484,9 +499,11 @@ -(BOOL)uploadFile __weak TUSResumableUpload * weakself = self; - UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - [weakself cancel]; - }]; + #if TARGET_OS_IPHONE + UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ + [weakself cancel]; + }]; + #endif self.currentTask = [self.delegate.session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error){ if (weakself.currentTask){ // Should only be false if self has been destroyed, but we need to account for that because of the removeTask call. [weakself.delegate removeTask:weakself.currentTask]; @@ -523,7 +540,11 @@ -(BOOL)uploadFile } weakself.idle = YES; [weakself.delegate saveUpload:weakself]; // Save current state for reloading - only save when we get a call back, not at the start of one (because this is the only time the state changes) - [[UIApplication sharedApplication] endBackgroundTask:bgTask]; + #if TARGET_OS_IPHONE + [[UIApplication sharedApplication] endBackgroundTask:bgTask]; + #elif TARGET_OS_MAC + [weakself cancel]; + #endif [weakself continueUpload]; // Continue upload, not resume, because we do not want to continue if cancelled. }]; [self.delegate addTask:self.currentTask forUpload:self]; diff --git a/TUSKit.podspec b/TUSKit.podspec index 01c2d1f5..c9fc4496 100755 --- a/TUSKit.podspec +++ b/TUSKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "TUSKit" - s.version = "1.3.8" + s.version = "1.3.9" s.summary = "An iOS implementation of the tus resumable video upload protocol." s.description = <<-DESC An iOS implementation of the tus resumable video upload protocol.