NSDataDetector issues in Xcode 13.1

I noticed a difference in NSDataDetector's behaviour between Xcode 12.5.1 and Xcode 13.1 when running my application's unit tests.

I extracted the relevant parts in this playground, and posted the different results in the repository's README. You can simply run this playground using different Xcode versions and see it for yourself:

https://github.com/vruzeda/NSDataDetector

I'm not 100% to the cause (if it's Xcode 13, iOS 15 SDK, or anything else). I'm running the exact same code in the same Mac (running Big Sur 11.6.1), the "only" variable I changed were Xcode versions.

Is this an expected change? Or is this a system bug?

Thanks!

I’d like to clarify your test methodology…

I put the code from your playground into a macOS command-line tool project and, running on macOS 11.6.1, the tool generates the same output when built with Xcode 12.5.1 and Xcode 13.1. I also took those binaries and ran them on macOS 12.0.1 and they produced the same results there, suggesting that there’s no link-on-or-later check in play.

I’ve seen numerous cases where playgrounds behave differently from code running in a normal app, but I don’t think that’s the issue here because, presumably, you created this playground to isolate an issue that shows up in your real app. Right?

With regards your real app, under what circumstances does it exhibit this problem? You mentioned the iOS 15 SDK, which suggests that your real app is targeting iOS. Is that right? If you create a test app using Xcode 12 from one of its built-in iOS templates, does that exhibit the behaviour? If so, under what circumstances?

Share and Enjoy

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

Thanks for the quick reply, @eskimo!

You are right, I extracted some of my application's behaviour into that playground. To make it clearer, I updated the repo (and renamed it, sorry), converting it into an iOS project.

https://github.com/vruzeda/DataDetector

I verified that the behaviour is consistent when running this app in an actual device, but you can now clearly see the different behaviours when running in the simulator or running the unit tests. For example, here are the output of the unit tests in the different Xcode versions:

Xcode 12.5.1:

Xcode 13.1:

I verified that the behaviour is consistent when running this app in an actual device

So how did you test that, given that Xcode 12 won’t let you run on an iOS 15 device?

It is possible to run such a test — you use the organiser to export a .ipa and then install that using the Finder — but it doesn’t sound like you’ve gone to that extreme.

Share and Enjoy

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

So how did you test that, given that Xcode 12 won’t let you run on an iOS 15 device?

Honestly, I don't see how that question is pertinent to the problem. What I'm describing is bluntly clear if you run the sample project I linked there as described.

But, answering the question, I first built my actual application using both Xcode versions and deployed it to the device using Xcode's "Devices and Simulators" to install the .ipa, so I did go to that extreme.

I also checked Xcode 13.2 Release Candidate (13C90), and the issue is still reproducible.

I’m sorry but I’m having trouble understanding the exact sequence of events you’re using to reproduce the problem. The sample you linked to is an iOS app with two cases:

  • Xcode 12.5.1

  • Xcode 13.1

However, you’ve said that the problem reproduces in the simulator, which means that the simulated iOS version comes into play. Xcode 13 can run apps in both the iOS 15 and iOS 14 simulator, while Xcode 12 can only run apps in the iOS 14 simulator. And the instructions in your read me don’t clarify which simulator version you’re using, that is, whether:

  • In the Xcode 13 case, you’re building with Xcode 13 but running on the iOS 14 simulator.

  • You’re using the default simulator in each case, that is, the iOS 14 simulator from Xcode 12 and the iOS 15 simulator from Xcode 13.

To offer a more a detailed answer I need a definitive set of steps that I can try here.


Notwithstanding the above, if you’re having a problem that only shows up in the simulator then that is, by definition, a bug in the simulator and I encourage you to file it as such. If you do that, make sure to be clear about the exact steps you took, because the simulator team will need the same sort of info that I’ve been trying to get here.

Please post your bug number, just for the record.

Share and Enjoy

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

Your questions helped me narrow down the issue to Simulator versions, it's unrelated to Xcode versions. So, I submitted a feedback, here you have it: FB9804292 (Inconsistent NSDataDetector's behaviour in iOS 15.0 Simulators)

Please describe the issue:

NSDataDetector's behaviour in iOS 15.0's Simulators is inconsistent with other iOS versions' Simulators and actual devices.

Please list the steps you took to reproduce the issue:

  1. Open the attached sample project in Xcode 13.1 (13A1030d) (also reproduced in Xcode 13.2 (13C90))
  2. Run the unit tests using an iOS 14.5's Simulator
  3. Run the unit tests using an iOS 15.0's Simulator

What did you expect to happen?

Unit tests should consistently pass on both iOS 14.5 and iOS 15.0 Simulators.

What actually happened?

Unit tests pass on iOS 14.5 Simulators, but fail on iOS 15.0 Simulators.

Thanks again!

NSDataDetector issues in Xcode 13.1
 
 
Q