Xcode: String interpolation / String(describing:) automatic fix broken

Hi! imagine this

guard let foo = bar.baz else {
    print("\(foo.value)")
    return foo.value
}

I get Xcode error String interpolation produces a debug description for an optional value; did you mean to make this explicit? with the fixing option: Use 'String(describing:)' to silence this warning

When I click Fix button I got:

guard let foo = bar.baz else {
    print("\(foString(describing: o.value)"))
    return foo.value
}

The automatic completion is broken. Is it a known bug or there is something wrong with me? ;)

  • Xcode version 15.3 (15E204a)
  • macOS Sonoma 14.4.1 (23E224)
  • Apple M1 Pro

Replies

It's not a bug. That's just to warn you that print may show an optional

optional(some value)

But you don't have to care for a print on the console.

Please show complete code.

  • No, it's putting the fix in the middle of foo, i.e. foStinrg(describing: o.value). Looks like an Xcode bug to me.

Add a Comment