The app will crash on IOS 18 when send a network request

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.URLCache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024
                                                        diskCapacity:100 * 1024 * 1024
                                                            diskPath:@"myCache"];
if (!configuration) {
    NSLog(@"Failed to create session configuration.");
    return;
}


NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
if (!session) {
    NSLog(@"Failed to create session.");
    return;
}

 
NSURL *url = [NSURL URLWithString:@"https://example.com"];
if (!url) {
    NSLog(@"Invalid URL.");
    return;
}

NSURLRequest *request = [NSURLRequest requestWithURL:url];
if (!request) {
    NSLog(@"Failed to create request.");
    return;
}
 
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
    if (error) {
        NSLog(@"Error: %@", error.localizedDescription);
    } else {
   
        NSLog(@"Data received: %@", data);
    }
}];

if (!dataTask) {
    NSLog(@"Failed to create data task.");
    return;
}
 
dataTask.priority = NSURLSessionTaskPriorityDefault;  

 
[dataTask resume];

error message

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSFileManager createDirectoryAtURL:withIntermediateDirectories:attributes:error:]: URL is nil'
*** First throw call stack:
(0x1848bd08c 0x181bbf2e4 0x183585f48 0x185d2f2bc 0x185d2ec7c 0x10709271c 0x1070a3f04 0x185d2ea88 0x185d2db20 0x185d2d5f4 0x185d2d07c 0x185d274b0 0x185dd82c4 0x185dd8214 0x185dd730c 0x107090a30 0x10709271c 0x10709a5e8 0x10709b394 0x10709cb20 0x1070a85f0 0x1070a7c00 0x20bc27c7c 0x20bc24488)
libc++abi: terminating due to uncaught exception of type NSException
Answered by DTS Engineer in 805067022

This looks like the issue we’re discussing on this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Me too. The same goes for error messages

Me too. The same goes for error messages;

NSString *strurl = @"https://example.com"; NSURLSession *session = [NSURLSession sharedSession]; NSURL *url = [NSURL URLWithString:strurl]; NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { if (error) { NSLog(@"Error: %@", error.localizedDescription); } else {

    NSLog(@"Data received: %@", data);
}
}];
[dataTask resume];

log: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSFileManager createDirectoryAtURL:withIntermediateDirectories:attributes:error:]: URL is nil' *** First throw call stack: (0x193f5108c 0x1912532e4 0x192c19f48 0x1953c32bc 0x1953c2c7c 0x10891271c 0x108923f04 0x1953c2a88 0x1953c1b20 0x1953c15f4 0x1953c107c 0x1953bb4b0 0x19546c2c4 0x19546c214 0x19546b30c 0x108910a30 0x10891271c 0x10891a5e8 0x10891b394 0x10891cb20 0x1089285f0 0x108927c00 0x21b2b3c7c 0x21b2b0488) libc++abi: terminating due to uncaught exception of type NSException

This looks like the issue we’re discussing on this thread.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for your reminder, check the code ,we didn't find any swizzling method on NSFileManager have been used. I've uploaded the log ,could you help check the error log to see if it can help identify the problem ?

The app will crash on IOS 18 when send a network request
 
 
Q