Expand on Swift macros

RSS for tag

Discuss the WWDC23 session Expand on Swift macros

Posts under wwdc2023-10167 tag

1 Post
Sort by:

Post

Replies

Boosts

Views

Activity

OSLog in Swift macro doesn't persist original file/line number
I need to log to OSLog and into a file in parallel (due to OSLogStore not being able to provide old logs (FB13191608)). In Objective-C I can accomplish this with a macro using __FILE__ and __LINE__ in the macro implementation which still reference the position in the original code. I tried to create a Swift macro to make this work from Swift. However, log() takes the file and line number of the macro definition file instead of the position in the calling code. So when I click on the metadata link, I'm taken to the macro instead of the calling location. Is there any solution to that? #file and #line are correctly set in the macro but there’s no way to specify file and line number to the log() function (FB13204310).
5
0
1.2k
Oct ’23