macOS 10.13: "Scheduling the NSURLDownload loader is no longer supported."

1.2k views Asked by At

Running my macOS app in macOS 10.13, I see printed to the console:

Scheduling the NSURLDownload loader is no longer supported.

What does this mean?

3

There are 3 answers

0
Jerry Krinock On

It appears to mean You have just created an instance of the deprecated class NSURLDownload.

To show this, create a new Cocoa command-line tool project in Xcode and replace the code in main.m with the following:

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSURL* url = [[NSURL alloc] initWithString:@"https://example.com"];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url                                                                        
                                                               cachePolicy:NSURLRequestReloadIgnoringCacheData
                                                           timeoutInterval:30.0];
        NSLog(@"Will print strange sentence to console") ;
        [[NSURLDownload alloc] initWithRequest:request
                                      delegate:nil];
        NSLog(@"Did print strange sentence to console") ;
    }
    return 0;
}

Build and run. I get the following result in console (timestamps removed):

Will print strange sentence to console:
Scheduling the NSURLDownload loader is no longer supported.
Did print strange sentence to console

I would say the "fix" is to replace the deprecated NSURLDownload with NSURLSession.

2
granada29 On

The Sparkle Updater seems to be the culprit in the instances I have found. I guess the Sparkle dev team will be on to it and hopefully we'll no longer see the message after Sparkle is updated.

0
Conor On

You can correct it directly in the source code for Sparkle. Update SUAppcast.m file at line 82 by replace the NSURLDownload with the following:

NSURLSessionDownloadTask *downloadTask = [[NSURLSession sharedSession] downloadTaskWithRequest:request completionHandler:^(NSURL *location, __unused NSURLResponse *response, NSError *error) {

    if (location) {
        NSString *destinationFilename = NSTemporaryDirectory();
        if (destinationFilename) {
            // The file will not persist if not moved, Sparkle will remove it later. 
            destinationFilename = [destinationFilename stringByAppendingPathComponent:@"Appcast.xml"];

            NSFileManager *fileManager = [NSFileManager defaultManager];
            NSError *anError = nil;
            NSString *fromPath = [location path];
            if ([fileManager fileExistsAtPath:destinationFilename])
                [fileManager removeItemAtPath:destinationFilename error:&anError];
            BOOL fileCopied = [fileManager moveItemAtPath:fromPath toPath:destinationFilename error:&anError];
            if (fileCopied == NO) {
                [self reportError:anError];
            } else {
                self.downloadFilename = destinationFilename;

                dispatch_async(dispatch_get_main_queue(), ^{
                    [self downloadDidFinish:[[NSURLDownload alloc] init]];
                });
            }
        }
    } else {
            [self reportError:error];
    }
 }];

[downloadTask resume];