SIL manipulation

Hi,

I would like to be able to replace at compile time a API call (4ex: downloadTask(with: URL) -> URLSessionDownloadTask from URLSession) with one of my own with the same signature.
Basically some sort of instrumentation.
I've considered AST parsing but I find this solution a bit unreliable.
My other two possibilities would be Swift SIL and LLVM IR. However I lack the high level overview to decide what would be the best approach in this case, and google doesn't help also. :frowning:

So given the available tooling and the need to be able to integrate the solution in a normal Xcode workflow, what would be the best approach?

Are you talking about “swizzling”?

The end effect would be indeed similar. But I'm asking about a compile time solution not a runtime one like “swizzling”. But also a “swizzling” like solution would be interesting.