Text string interpolation formatter bug with MeasurementFormatter when changing a locale setting

Originator:indiekiduk
Number:rdar://FB8817280 Date Originated:21/10/20
Status:Open Resolved:
Product:SwiftUI Product Version:Xcode Version 12.2 beta 3 (12B5035g)
Classification:Bug Reproducible:Always
 
Using the Text View with string interpolation and a formatter has a bug when supplying a MeasurementFormatter. If I configure a MeasurementFormatter's numberFormatter, when I pass as the formatter param to a Text view, if I change a locale setting, e.g. the Temperature format in the Settings app, then my measurement formatter loses its number formatting.  I've attached a sample project that demonstrates the problem.

 1. Launch application in iPhone SE Simulator.
 2. The number is output with 6 fractional digits as the formatter specified.
 3. Keep app running, go to homescreen, open Settings app, General, Language & Region, Temperature Unit, change it from C to F or vice versa.
 4. Switch back to the running app.
 
 What expect to happen:
 Number should still be 6 decimals.
 
 What actually happens:
 Number is shown with only 3 decimals.

Additional info
I've tested the behaviour of the MeasurementFormatter in ObjC and Swift apps and I have only experienced the problem in SwiftUI. Also in SwiftUI if I do not pass the formatter into a Text then the issue does not happen, e.g. Text(degreesFormatter.string(from:degrees))

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!