URLSessionConfiguration to set usesClassicLoadingMode as false

When i try to set the value ‘false’ for ‘usesClassicLoadingMode’ it is getting crashed.

The crash logs has been shared below

Ex: let config = URLSessionConfiguration.default if #available(iOS 18.4, *) { config.usesClassicLoadingMode = false } Error log : *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean objectForKeyedSubscript:]: unrecognized selector sent to instance 0x1f655c390' *** First throw call stack: (0x188ae52ec 0x185f69a7c 0x188b4f67c 0x1889fcb84 0x1889fc4f0 0x191393bc8 0x1889ec8a0 0x1889ec6e4 0x191393ad0 0x191344dac 0x191344b58 0x107cfa064 0x107ce36d0 0x191343fcc 0x1891b3b18 0x1892dae58 0x189235c60 0x18921e270 0x18921d77c 0x18921a8ac 0x107ce0584 0x107cfa064 0x107ce891c 0x107ce95d8 0x107ceabcc 0x107cf5894 0x107cf4eb0 0x212f51660 0x212f4e9f8) terminating due to uncaught exception of type NSException

Can you please provider the resolution steps

Answered by Frameworks Engineer in 834913022

NSExceptionDomains dictionary‘s keys are domains. They are individual domain overrides for ATS. NSExceptionAllowsInsecureHTTPLoads and NSIncludesSubdomains are in a nested dictionary of the specific domain.

how to fix this crash, can you please provide the steps

Please post a full crash report for this, per the advice in Posting a Crash Report.

Share and Enjoy

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

please check the screenshot

find the crash details below :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean objectForKeyedSubscript:]: unrecognized selector sent to instance 0x1f655c390' *** First throw call stack: (0x188ae52ec 0x185f69a7c 0x188b4f67c 0x1889fcb84 0x1889fc4f0 0x191393bc8 0x1889ec8a0 0x1889ec6e4 0x191393ad0 0x191344dac 0x191344b58 0x107cfa064 0x107ce36d0 0x191343fcc 0x1891b3b18 0x1892dae58 0x189235c60 0x18921e270 0x18921d77c 0x18921a8ac 0x107ce0584 0x107cfa064 0x107ce891c 0x107ce95d8 0x107ceabcc 0x107cf5894 0x107cf4eb0 0x212f51660 0x212f4e9f8) terminating due to uncaught exception of type NSException

I’m sorry but what you posted doesn’t help. Your first follow-up post is a screen shot and your second is just a repeat of stuff that you put in your original question. I need a crash report. Posting a Crash Report has lots of info on how to get that.

If you post a crash report, I should be able to offer further advice.

ps Quinn’s Top Ten DevForums Tips has a bunch of advice on how to use the forums effectively.

Share and Enjoy

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

Please check if your NSAppTransportSecurity dictionary in Info.plist is valid. This could be a known issue if you use the wrong type in the dictionary.

I am able to fetch below crash report from the XCode debugger,


(lldb) thread backtrace

  • thread #12, queue = 'com.apple.NWURLSession', stop reason = hit Objective-C exception
    • frame #0: 0x0000000185f69a24 libobjc.A.dylibobjc_exception_throw frame #1: 0x0000000188b4f67c CoreFoundation-[NSObject(NSObject) doesNotRecognizeSelector:] + 364 frame #2: 0x00000001889fcb84 CoreFoundation___forwarding___ + 1492 frame #3: 0x00000001889fc4f0 CoreFoundation_CF_forwarding_prep_0 + 96 frame #4: 0x0000000191393bc8 Security__sec_protocol_configuration_set_ats_overrides_block_invoke + 160 frame #5: 0x00000001889ec8a0 CoreFoundationNSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK + 24 frame #6: 0x00000001889ec6e4 CoreFoundation-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 288 frame #7: 0x0000000191393ad0 Securitysec_protocol_configuration_set_ats_overrides + 1024 frame #8: 0x0000000191344dac Securitysec_protocol_configuration_create_with_builder + 548 frame #9: 0x0000000191344b58 Security__sec_protocol_configuration_copy_singleton_block_invoke + 36 frame #10: 0x0000000107cce064 libdispatch.dylib_dispatch_client_callout + 16 frame #11: 0x0000000107cb76d0 libdispatch.dylib_dispatch_once_callout + 140 frame #12: 0x0000000191343fcc Securitysec_protocol_configuration_copy_singleton + 72 frame #13: 0x00000001891b3b18 Network__34-[NWURLLoaderHTTP continueLoading]_block_invoke + 276 frame #14: 0x00000001892dae58 Networknw_parameters_create_secure_http_messaging + 452 frame #15: 0x0000000189235c60 Network-[NWURLLoaderHTTP continueLoading] + 424 frame #16: 0x000000018921e270 Network__25-[NWURLLoaderHTTP start:]_block_invoke + 1272 frame #17: 0x000000018921d77c Network-[NWURLLoaderHTTP start:] + 700 frame #18: 0x000000018921a8ac Network__34-[NWURLSessionTask startNextLoad:]_block_invoke + 164 frame #19: 0x0000000107cb4584 libdispatch.dylib_dispatch_call_block_and_release + 32 frame #20: 0x0000000107cce064 libdispatch.dylib_dispatch_client_callout + 16 frame #21: 0x0000000107cbc91c libdispatch.dylib_dispatch_lane_serial_drain + 796 frame #22: 0x0000000107cbd5d8 libdispatch.dylib_dispatch_lane_invoke + 484 frame #23: 0x0000000107cbebcc libdispatch.dylib_dispatch_workloop_invoke + 2196 frame #24: 0x0000000107cc9894 libdispatch.dylib_dispatch_root_queue_drain_deferred_wlh + 344 frame #25: 0x0000000107cc8eb0 libdispatch.dylib_dispatch_workloop_worker_thread + 580 frame #26: 0x0000000212f51660 libsystem_pthread.dylib`_pthread_wqthread + 292

(lldb) frame variable (NSException *) exception = 0x00000001100f1d40 "-[__NSCFBoolean objectForKeyedSubscript:]: unrecognized selector sent to instance 0x1f655c390"


*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean objectForKeyedSubscript:]: unrecognized selector sent to instance 0x1f655c390'

*** First throw call stack:

(0x188ae52ec 0x185f69a7c 0x188b4f67c 0x1889fcb84 0x1889fc4f0 0x191393bc8 0x1889ec8a0 0x1889ec6e4 0x191393ad0 0x191344dac 0x191344b58 0x104dae064 0x104d976d0 0x191343fcc 0x1891b3b18 0x1892dae58 0x189235c60 0x18921e270 0x18921d77c 0x18921a8ac 0x100856df4 0x104d94584 0x104dae064 0x104d9c91c 0x104d9d5d8 0x104d9ebcc 0x104da9894 0x104da8eb0 0x212f51660 0x212f4e9f8)

terminating due to uncaught exception of type NSException

(lldb) thread backtrace

  • thread #13, queue = 'com.apple.NWURLSession', stop reason = signal SIGABRT

    • frame #0: 0x00000001d95d21dc libsystem_kernel.dylib`__pthread_kill + 8

      frame #1: 0x0000000212f54b40 libsystem_pthread.dylib`pthread_kill + 268

      frame #2: 0x0000000190a052d0 libsystem_c.dylib`abort + 124

      frame #3: 0x0000000212e7e5a0 libc++abi.dylib`abort_message + 132

      frame #4: 0x0000000212e6cf10 libc++abi.dylib`demangling_terminate_handler() + 344

      frame #5: 0x0000000185f6bbb8 libobjc.A.dylib`_objc_terminate() + 156

      frame #6: 0x0000000212e7d8b4 libc++abi.dylib`std::__terminate(void (*)()) + 16

      frame #7: 0x0000000212e80e1c libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 88

      frame #8: 0x0000000212e80dc4 libc++abi.dylib`__cxa_throw + 92

      frame #9: 0x0000000185f69be4 libobjc.A.dylib`objc_exception_throw + 448

      frame #10: 0x0000000188b4f67c CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 364

      frame #11: 0x00000001889fcb84 CoreFoundation`forwarding + 1492

      frame #12: 0x00000001889fc4f0 CoreFoundation`_CF_forwarding_prep_0 + 96

      frame #13: 0x0000000191393bc8 Security`__sec_protocol_configuration_set_ats_overrides_block_invoke + 160

      frame #14: 0x00000001889ec8a0 CoreFoundation`NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK + 24

      frame #15: 0x00000001889ec6e4 CoreFoundation`-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 288

      frame #16: 0x0000000191393ad0 Security`sec_protocol_configuration_set_ats_overrides + 1024

      frame #17: 0x0000000191344dac Security`sec_protocol_configuration_create_with_builder + 548

      frame #18: 0x0000000191344b58 Security`__sec_protocol_configuration_copy_singleton_block_invoke + 36

      frame #19: 0x0000000104dae064 libdispatch.dylib`_dispatch_client_callout + 16

      frame #20: 0x0000000104d976d0 libdispatch.dylib`_dispatch_once_callout + 140

      frame #21: 0x0000000191343fcc Security`sec_protocol_configuration_copy_singleton + 72

      frame #22: 0x00000001891b3b18 Network`__34-[NWURLLoaderHTTP continueLoading]_block_invoke + 276

      frame #23: 0x00000001892dae58 Network`nw_parameters_create_secure_http_messaging + 452

      frame #24: 0x0000000189235c60 Network`-[NWURLLoaderHTTP continueLoading] + 424

      frame #25: 0x000000018921e270 Network`__25-[NWURLLoaderHTTP start:]_block_invoke + 1272

      frame #26: 0x000000018921d77c Network`-[NWURLLoaderHTTP start:] + 700

      frame #27: 0x000000018921a8ac Network`__34-[NWURLSessionTask startNextLoad:]_block_invoke + 164

      frame #28: 0x0000000100856df4 libclang_rt.asan_ios_dynamic.dylib`__wrap_dispatch_async_block_invoke + 196

      frame #29: 0x0000000104d94584 libdispatch.dylib`_dispatch_call_block_and_release + 32

      frame #30: 0x0000000104dae064 libdispatch.dylib`_dispatch_client_callout + 16

      frame #31: 0x0000000104d9c91c libdispatch.dylib`_dispatch_lane_serial_drain + 796

      frame #32: 0x0000000104d9d5d8 libdispatch.dylib`_dispatch_lane_invoke + 484

      frame #33: 0x0000000104d9ebcc libdispatch.dylib`_dispatch_workloop_invoke + 2196

      frame #34: 0x0000000104da9894 libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 344

      frame #35: 0x0000000104da8eb0 libdispatch.dylib`_dispatch_workloop_worker_thread + 580

      frame #36: 0x0000000212f51660 libsystem_pthread.dylib`_pthread_wqthread + 292


I’d still like to see an actual crash report.

If you’re able to catch this in Xcode’s debugger then you can generate a crash report from there. The docs linked to by Posting a Crash Report explain how to do that.

I keep asking for a crash report and you keep posting stuff that’s not a crash report )-: This will go a lot smoother if you actually do that. A crash report will let me quickly understand the context of this failure. The screen shots and bits of debugging snippets you’ve posted so far are very hard to interpret.

Share and Enjoy

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

Can you please find the crash report file below and do needful

=========================

Thanks for that.

Consider this snippet from your crash report:

Exception Reason: -[__NSCFBoolean objectForKeyedSubscript:]: unrecognized selector sent to instance 0x2031fc390

It indicates that something is trying to treat an NSNumber containing a Boolean value as if it were a dictionary. That’s not good. So let’s look at who that is:

Last Exception Backtrace:…
0   CoreFoundation          … __exceptionPreprocess + 164 (NSException.m:249)
1   libobjc.A.dylib         … objc_exception_throw + 88 (objc-exception.mm:356)
2   CoreFoundation          … -[NSObject(NSObject) doesNotRecognizeSelector:] + 364 (NSObject.m:162)
3   CoreFoundation          … ___forwarding___ + 1492 (NSForwarding.m:3612)
4   CoreFoundation          … _CF_forwarding_prep_0 + 96
5   Security                … __sec_protocol_configuration_set_ats_overrides_block_invoke + 160 (SecProtocolCon…
6   CoreFoundation          … __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 24 (NSDictionaryHelpers.m:10)
7   CoreFoundation          … -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 288 (NSDictio…
8   Security                … sec_protocol_configuration_set_ats_overrides + 1024 (SecProtocolConfiguration.m:7…
9   Security                … sec_protocol_configuration_create_with_builder + 548 (SecProtocolTypes.m:1009)
10  Security                … __sec_protocol_configuration_copy_singleton_block_invoke + 36 (SecProtocolConfigu…
11  libdispatch.dylib       … _dispatch_client_callout + 16 (client_callout.mm:85)
12  libdispatch.dylib       … _dispatch_once_callout + 32 (once.c:52)
13  Security                … sec_protocol_configuration_copy_singleton + 72 (SecProtocolConfiguration.m:76)
14  Network                 … __34-[NWURLLoaderHTTP continueLoading]_block_invoke + 276 (NWURLLoaderHTTP.m:418)
15  Network                 … nw_parameters_create_secure_http_messaging + 452 (parameters.cpp:9145)
16  Network                 … -[NWURLLoaderHTTP continueLoading] + 424 (NWURLLoaderHTTP.m:392)
17  Network                 … __25-[NWURLLoaderHTTP start:]_block_invoke + 1272 (NWURLLoaderHTTP.m:312)
18  Network                 … -[NWURLLoaderHTTP start:] + 700 (NWURLLoaderHTTP.m:318)
19  Network                 … __34-[NWURLSessionTask startNextLoad:]_block_invoke + 164 (NWURLSessionTask.m:373)
20  libdispatch.dylib       … _dispatch_call_block_and_release + 32 (init.c:1575)
21  libdispatch.dylib       … _dispatch_client_callout + 16 (client_callout.mm:85)
22  libdispatch.dylib       … _dispatch_lane_serial_drain + 740 (queue.c:3939)
23  libdispatch.dylib       … _dispatch_lane_invoke + 440 (queue.c:4030)
24  libdispatch.dylib       … _dispatch_workloop_invoke + 1612 (queue.c:4709)
25  libdispatch.dylib       … _dispatch_root_queue_drain_deferred_wlh + 292 (queue.c:7198)
26  libdispatch.dylib       … _dispatch_workloop_worker_thread + 540 (queue.c:6792)
27  libsystem_pthread.dylib … _pthread_wqthread + 292 (pthread.c:2696)
28  libsystem_pthread.dylib … start_wqthread + 8

This is all system code. However, frame 5 is interesting. The method name is __sec_protocol_configuration_set_ats_overrides_block_invoke, where the ats indicates App Transport Security. This brings me back to the point my colleague made earlier:

Please check if your NSAppTransportSecurity dictionary in Info.plist is valid. This could be a known issue if you use the wrong type in the dictionary.

The exception backtrace in your crash report strongly indicates that you’re hitting this problem. It’s most likely that the NSAppTransportSecurity property in your Info.plist has a Boolean value where ATS is expecting a dictionary.

What does your NSAppTransportSecurity dictionary look like?

Share and Enjoy

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

the 'NSAppTransportSecurity' property having Boolean value that is removed from the info.plist

<key>NSAllowsArbitraryLoads</key>

<dict>

	<key>NSAllowsArbitraryLoadsForMedia</key>

	<true/>

** <key>NSAppTransportSecurity</key>

	<true/>

</dict>**

<key>NSAppTransportSecurity</key>

<dict>

	<key>NSAllowsArbitraryLoads</key>

	<true/>

	<key>NSExceptionDomains</key>

	<dict>

		<key>NSExceptionAllowsInsecureHTTPLoads</key>

		<true/>

		<key>NSIncludesSubdomains</key>

		<true/>

	</dict>

</dict>

but still we are getting the crash please find the below crash report

I’d like to see the Info.plist embedded in your app, just to make sure it matches the values you’ve shown above. Please do this:

  1. Build your app.

  2. Run it and reproduce the crash.

  3. In Xcode, choose Product > Copy Build Folder Path.

  4. In Terminal, create a new window and cd to that path:

    % cd "<PATH_FROM_STEP_3>"
    
  5. Now cd into appropriate build directory. For example, if you built the app for the device, do this:

    % cd "Products/Debug-iphoneos"
    
  6. Dump the Info.plist of the built app:

    % plutil -p "MyApp.app/Info.plist" 
    {
      "BuildMachineOSBuild" => "24D81"
      …
    }
    

    Replace MyApp with the name of your app.

  7. Copy that output and paste that into a reply here.

IMPORTANT Use a code block for this output. That’ll ensure it renders nicely. See tip 6 in Quinn’s Top Ten DevForums Tips.

Share and Enjoy

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

Please find the output of plist

 {
  "branch_key" => {
    "live" => "key_live_gBfD4a8YnXF0ISX4DRjPLjicvrlOQxwV"
  }
  "branch_universal_link_domains" => [
    0 => "myim3.app.link"
    1 => "myim3-alternate.app.link"
  ]
  "CFBundleURLTypes" => [
    0 => {
      "CFBundleURLSchemes" => [
        0 => "com.googleusercontent.apps.876546145137-li1hggkophps33mgq6b991ql4ao8h4i5"
      ]
    }
    1 => {
      "CFBundleTypeRole" => "Editor"
      "CFBundleURLSchemes" => [
        0 => "fb2572246932852997"
      ]
    }
    2 => {
      "CFBundleTypeRole" => "Editor"
      "CFBundleURLName" => ""
      "CFBundleURLSchemes" => [
        0 => "myim3"
      ]
    }
    3 => {
      "CFBundleTypeRole" => "Editor"
      "CFBundleURLName" => ""
      "CFBundleURLSchemes" => [
        0 => "myim3branch"
      ]
    }
    4 => {
      "CFBundleTypeRole" => "Editor"
      "CFBundleURLSchemes" => [
        0 => "taraindepay-com.pure.indosat.care"
      ]
    }
  ]
  "CleverTapDisableIDFV" => 1
  "CleverTapRegion" => "eu1"
  "CleverTapUseIFA" => 0
  "FacebookAppID" => "2572246932852997"
  "FacebookClientToken" => "CLIENT-TOKEN"
  "FacebookDisplayName" => "myIM3"
  "FirebaseAppDelegateProxyEnabled" => 0
  "FirebaseAutomaticScreenReportingEnabled" => 0
  "GADApplicationIdentifier" => "ca-app-pub-3436667638858341/5465581181"
  "GADIntegrationManager" => "webview"
  "GIDClientID" => "876546145137-li1hggkophps33mgq6b991ql4ao8h4i5.apps.googleusercontent.com"
  "ITSAppUsesNonExemptEncryption" => 0
  "LSApplicationQueriesSchemes" => [
    0 => "comgooglemaps"
    1 => "gojek"
    2 => "taraindepay-com.pure.indosat.care"
    3 => "fbapi"
    4 => "fb-messenger-share-api"
    5 => "fbauth2"
    6 => "fbshareextension"
    7 => "whatsapp"
  ]
  "NSAllowsArbitraryLoads" => {
    "NSAllowsArbitraryLoadsForMedia" => 1
  }
  "NSAppTransportSecurity" => {
    "NSAllowsArbitraryLoads" => 1
    "NSExceptionDomains" => {
      "NSExceptionAllowsInsecureHTTPLoads" => 1
      "NSIncludesSubdomains" => 1
    }
  }
  "PHPhotoLibraryPreventAutomaticLimitedAccessAlert" => 1
  "UIAppFonts" => [
    0 => "NotoSans-Bold.ttf"
    1 => "NotoSans-Light.ttf"
    2 => "NotoSans-LightItalic.ttf"
    3 => "NotoSans-Regular.ttf"
    4 => "Ooredoo-Heavy.otf"
    5 => "NotoSans-BoldItalic.ttf"
    6 => "NotoSans-Italic.ttf"
    7 => "HelveticaNeue-Bold.ttf"
    8 => "HelveticaNeue.ttf"
  ]
  "UIApplicationSceneManifest" => {
    "UIApplicationSupportsMultipleScenes" => 0
  }
  "UIBackgroundModes" => [
    0 => "fetch"
    1 => "remote-notification"
  ]
  "UIViewControllerBasedStatusBarAppearance" => 1
}
Accepted Answer

NSExceptionDomains dictionary‘s keys are domains. They are individual domain overrides for ATS. NSExceptionAllowsInsecureHTTPLoads and NSIncludesSubdomains are in a nested dictionary of the specific domain.

URLSessionConfiguration to set usesClassicLoadingMode as false
 
 
Q