How can I break on this error in Xcode?

I'm getting this error in the console:

*** -[__NSCFString substringWithRange:]: Range {18446744073709551615, 1} out of bounds; string length 43. This will become an exception for apps linked after 10.10 and iOS 8. Warning shown once per app execution.

Great! So I created a category on NSString for _substringWithRange and _***_stringByReplacingCharactersInRange that call the original method (note undescore), then changed every usage in my app to use my own method, in which I test for location == NSNotFound.

Nothing.

So I swizzled both methods, and again tested for NSNotFound, and again nothing.

What can I do to break when this error happens?

Thanks David

On which version of iOS do you test ? Is it Swift or objC code ?

If beyond iOS 8, you should see a crash. Do you get it ?

Do you use NSMakeRange ? If so, look here: https://stackoverflow.com/questions/11131472/substring-with-range-out-of-bounds

Can't you find which String is of length 43 ?

You have probably searched and found that:

https://stackoverflow.com/questions/24462014/substringwithrange-out-of-bounds-what-am-i-missing

and

https://github.com/realm/SwiftLint/issues/3761

How can I break on this error in Xcode?
 
 
Q