SwiftUI Text.strikethrough() not working

I have a piece of code that turns a string into a Text with attributes like italics, bold, etc. I apply attributes per character (or perhaps per stringIndex depending on the language) and then join everything using
.reduce(Text(""), {t1, t2 in t1 + t2 }).

The thing is that this had been working great (last time it worked was 7th September 2020), but now it turned out that is just stopped to work only for strikethrough(). It still works fine for bold(), italics() and underline().

I have iOS 14.1 installed on my iPhone and I build the project in xCode for iOS 14.0.

Looks like something might have changed in the underlying API for the strikethrough method.

The input string is in the following format:
Code Block
orange -> ein orang~er~ Wagen (^ein orang~eer~ Wagen^)

where
Code Block
~ - underline
^ - strikethrough


It works as follows:
  • I go through string indices to extract which indices have attributes, where the function returns the following type:

[String.Index: Set<Character>]

For instance for a string l~o^l^~ it should produce:
Code Block
[
1: [~],
2: [~],
3: [^, ~],
4: [^],
5: [~],
6: [~]
]
  • then I go through the string using its .indices, I discards the signs themselves and then apply attributes if the index is present in the aforementioned mapping of indices to attributes like this:

Code Block
func createAttributeText(str: String) -> Text {
let attributeIndices: [String.Index: Set<Character>] = ...
return str.indices.map { index in
if let attributes = attributeIndices[index] {
/* returns e.g. Text(str).strikethrough()
or Text(str).bold().strikethrough()
*/
return applyAttrs(text: str, attrs: attrs)
else {
return Text(str)
}
}
.reduce(Text(""), {t1, t2 in t1 + t2 })
}


and then

Code Block
VStack {
createAttributedText(str: someStringVariable)
}


I can swear that this worked and I haven't touched the code.

Is there any place where I can find a change log if there have been any changes to this part of the API? I tried to reproduce with a minimal example in another project, but so far it is working there so I need to keep digging.
Works in Preview, works in the Simulator (iPhone 11, 11 Pro), but doesn't work on my device (iPhone XR).
Ok, I figured out what doesn't work. Turns out that whenever Text objects are concatenated and more than a half of total characters that make up these object DON'T have strikethrough() applied, then the strikethrough() from the final concatenated object is removed. Strangely, this bug applies only to the strikethrough modifier and works fine for bold, italic and underline.

Filed a bug here: https://feedbackassistant.apple.com/feedback/8916878

See minimal example that reproduces this:

Code Block swift
import SwiftUI
struct TestView: View {
  var body: some View {
    VStack{
      Group {
        HStack {
          Text("Strikethrough test")
            .font(.largeTitle)
          Spacer()
        }
        Group {
          VStack { Text("TO TROLL") + Text(" OR NOT TO TROLL?").strikethrough() }
          VStack { Text("TO TROLL").strikethrough() + Text(" OR NOT TO TROLL?") }
        }
        .font(.body)
        Divider()
      }
    }
    .padding()
  }
}
struct TestView_Previews: PreviewProvider {
  static var previews: some View {
    TestView()
  }
}


SwiftUI Text.strikethrough() not working
 
 
Q