0

After upgrading an Xcode to 13.0 version and recompiling my app with it on a device I started getting this exception:

libc++abi: terminating with uncaught exception of type NSException dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSJSONReadingAssumeTopLevelDictionary and NSJSONReadingAllowFragments cannot be set at the same time' terminating with uncaught exception of type NSException

It seems that the problem is with new option topLevelDictionaryAssume added in JSONSerialization.ReadingOptions, available only for ios15.

What I've tried: I've checked all places where I had .allowFragments and replaced it with topLevelDictionaryAssume. It didn't help.

Any advice would be appreciated.

Alex Sh.
  • 579
  • 5
  • 17
  • In Swift you don't need `.allowFragments` at all if the expected object is a collection type. And even if it's not an array or dictionary in iOS13+ the framework is able to recognize fragments anyway. – vadian Sep 22 '21 at 09:59
  • i have to support ios10 and above – Alex Sh. Sep 22 '21 at 10:21
  • Again, if the expected type is a dictionary you can omit the `options` parameter, even in iOS 10. `.allowFragments` is only for a single string or number. – vadian Sep 22 '21 at 10:27
  • I got rid of all non-nil options in `[NSJSONSerialization dataWithObject]` and it seemed to work. Thank you. – Alex Sh. Sep 22 '21 at 11:44

0 Answers0