'Swift Package Manager BuildToolPlugin Network Access
I'm experimenting with the new BuildToolPlugin
for Swift Package Manager.
Evolution: https://github.com/apple/swift-evolution/blob/main/proposals/0303-swiftpm-extensible-build-tools.md
I have found, as the documentation says that network access is blocked
.
I'd quite like to download a configuration file when my plugin runs, but have no-way of doing so. Can anyone offer any work arounds, ie:
- Can I disable the sandbox for my plugin only?
- Is there a different approach to downloading files in a plugin?
- or am I plain stuck here?
Thank you
Chris
Solution 1:[1]
No, it's not possible nor it will ever be. You'll have to obtain the configuration file by other means (e.g. as part of the CI) before building.
You can read more about this in the proposal under How SwiftPM Applies Plugins to Targets:
Applying a plugin to a target is done by executing the Swift script that implements it, passing inputs that describe the target to which the plugin is being applied, and interpreting its outputs as instructions for SwiftPM. The plugin is run — either by interpreting it or by compiling it to an executable and running it — in a sandbox that prevents network access and that restricts file system access.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rad'Val |