Hi community, during SE-0196 I said that it would be really cool if we would eventually extend the language to emit runtime issues triggered by some compiler diagnostic directives.
This idea intrigued a few of the community members and even the core team mentioned it in the rationale:
Now I had the chance to watch the following WWDC session 'Debugging with Xcode 11'. I noticed that SwiftUI provides custom 'runtime issues' similar to the idea mentioned above.
-
Is this a hidden compiler feature or SwiftUI internal hook for Xcode?
-
In case of the former, can we expose it to the rest of the community?
cc @John_McCall @Joe_Groff @dabrahams @Douglas_Gregor
14 Likes
Let's bump this thread. Is there a chance we could possibly get this feature rolling? Maybe it's now the right time as we are currently discussing the concrete implementation for these directives as macros. (cc @Douglas_Gregor again)
Today I think this feature should be standalone and not tied to the directives. It should be something lightweight and on par with assert but without a failure. Maybe some kind of global emit function with parameters similar to print?
2 Likes
technogen
(Gor Gyolchanyan)
4
I'd love to see this feature being made official. It would be hugely helpful for writing robust, invariant-checking code!
1 Like
It's one of the things I was expecting them to release a separate package. It's so useful!
As the resources shared by @gwendal.roue indicate, runtime warnings occur by a call to the logging framework. However, instead of using your app's DSO handle, you use one of the Apple-internal frameworks, such as SwiftUI or Foundation.
Well I've seen that post, my original questions were three years old though. 
1 Like