iOS 16.1 breaks UITextView tokenizer for words (rangeEnclosingPosition: withGranularity : inDirection:)

We have an messaging application. In which we have a feature where it detect phone number and on tap of it we provide other options to user. Until release of iOS 16.1 version, it was working perfectly fine. But, After realise of iOS 16.1 and above we are experiencing a strange issue where it is not detecting the tap and not showing other options.  After debugging the code, we found that we are using below UIKit function to get the range or number on tap. But, In iOS 16.1 version it is returning null value. whereas, it was returning the range of number where it was tapped.  Below is the function which is returning nil value, Also attaching screenshot of code for better understanding.   **  textRange = [tokenizer rangeEnclosingPosition:tapPosition                           withGranularity:UITextGranularityWord                             inDirection:UITextLayoutDirectionRight];**

The built-in UITextView tokenizer function rangeEnclosingPosition(_:with:inDirection:) seems to have broken in iOS 16.1 for the “word” granularity. Word: doesn't seem to ever return a range.

We also tried this in a sample project. But, these issue is same on that project to.

Please fix this issue on upcoming release. As, this being one of the crucial part of our health messaging app. 

If possible, Please provide us a work around for this.

just try to change the inDirection: to UITextWritingDirection.rightToLeft.rawValue, this worked for me (even that it is logical wrong to me)

inDirection doesn't accept the type UITextWritingDirection. It accepts UITextDirection only. I guess iOS 16 broke the rangeEnclosingPosition function. But the UITextDirection.layout(.up) workaround worked for me.

iOS 16.1 breaks UITextView tokenizer for words (rangeEnclosingPosition: withGranularity : inDirection:)
 
 
Q