But I do not see fatalError messages in crash reports either! Was it changed since then and now, and if before we could have used condition+fatalError as a "better" version of precondition now this workaround doesn't work either?
I believe Apple intentionally removes the messages from crash reports in the name of privacy. If you use a more complex crash reporter system it may be able to extract extra info, but it's still pretty limited. Reporters like Crashlytics also have logging you can enable to help narrow down when a crash occurred, even if you can't get the exact message.
Quinn (@eskimo), just found your article mentioning MetricKit on iOS 14. The documentation is a bit too succinct, please confirm that that is NOT the right tool to achieve the wanted result (of getting the wanted string into the crash log).
It doesn't inform the compiler of the intention, and behaves identically in debug, release, and unchecked configurations, but, well: sometimes users are more important than compiler optimizations.
Beware on my sample code I use #file instead of one of its variants: I just pasted code written in early days of Swift and hadn't any opportunity to refresh it.
Using fatalError() instead of precondition() fixes the problem where you don't get error messages even in local development, which is what that user was complaining about. Neither of them log the error in crash reports.
One thing you might try is using OSLog to log the error reason then call fatalError() with no message. IIRC, the static part of an os_log message should appear in crash reports, but interpolated values from the program may be redacted. Since fatalError("...") and precondition("...") dynamically render the string before reporting it, it appears to the OS as if it's an entirely interpolated string, but using OSLog directly should avoid that.
Thanks for the tip. Could Swift solve this by offering overloads of fatalError and others to take a StaticString rather than the current String autoclosure?