Calling function in swift application from dependent module

Viewed 42

I have a Swift application that uses a module, and I need to call a global function that is in the application from the module, is this possible?

To perhaps explain a little better, this is a test app structure:

Example

CallbackTestApp contains a function foo(), I would like to call it from Module1 or File, will swift allow this?

edit #1

More details have been requested on what is the background of my issue, hopefully, this will not turn out to be an XY situation.

There's a tool developed by my company that process the application source* code and in some places add function call (ignore the why etc, have to be generic here.). Those function calls are exactly to foo() which then does some magic (btw, no return value and no arguments are allowed), if the application does not use modules or if modules are excluded from the processing then all is fine (Linker does not complain that the function is not defined), if there are modules then nothing works since I did not found a way to inject foo() (yet).

*Not exactly the source code, actually the bitcode is processed, the tool get the source, use llvm toolchain to generate bitcode, do some more magic and then add the call to foo() by generating it's mangled name and adding a swiftcall

Not actually sure those additional details will help.

0 Answers
Related