When I try to read file in swift macro develop, I meet this error, is there any way to read file in swift macro develop.
2 Likes
Hi! I don't think you can.
"Compiler plug-ins run in a sandbox that stops macro implementations from reading files on disk or accessing the network."
3 Likes
Yeah, please don't do this (and the sandbox will prevent you from doing so).
Macros should result in "the same" expansion and not arbitrarily change when some external things change. If this wasn't true, any code containing a macro would always have to be recompiled, significantly hurting compilation performance.
5 Likes
Can you simply put your configuration in a source file and edit it to set configuration?
Thank you for your explanation, I decided to write the configuration in the code
Could it be the same file but within a sources? Like ./Sources/config.yml