Error embedding file data with a macro

That was explained in my original message: source code placed on the file system is tracked by the build system, as source code file paths are known to the build system. Arbitrary side effects within Swift macros are opaque and unknown to the build system, breaking determinism and assumptions built on top of that determinism.

For the same reason that C gets to have unrestricted memory access and data races, but Swift does not thanks to its memory safety and strict concurrency. In the same way, macros in Swift are supposed to be free from side effects (partially enforced only on some platforms for now) to prevent build system errors and incorrect incremental builds.

You could embed data from a module written in C or C++, but do that at your own risk as Swift build system would have no way to ensure correctness of the build.

3 Likes