SPM build tool plugin support #209
vladvlasov256
started this conversation in
Ideas
Replies: 3 comments
-
Thank you for the nice proposal 👍
I'm welcome your pull request 🙏 |
Beta Was this translation helpful? Give feedback.
0 replies
-
The 2nd of 4 planned PRs is ready. The PR adds a binary target to the package. But mostly it's about automating artifact uploading for that target. It's |
Beta Was this translation helpful? Give feedback.
0 replies
-
Current progress:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Build Tools
As you probably know, Xcode 14 supports SPM build tool plugins. That means tools like mint could be replaced with the plugins.
LicensePlist Plugin
Today I was able to generate
Acknowledgements.plist
with a build plugin using patchedLicensePlist
. All related work is in this branch.I haven't updated the readme and tests yet but the plugin already could be used in Xcode.
Limitations
No Command-line Arguments
Build tool commands don't support command-line arguments. Thus all the configuration should be done in the config file. For this purpose, the plugin branch is based on another pull request's branch.
Write Access
Another limitation is that Xcode runs plugins in a sandbox. Plugin tools can read all project files but they can write only to their own output folders. At the same moment, Xcode automatically copies generated files to a build folder inside
Derived Data
. But that's not possible to simply generateSettings.bundle
directory because it's a kind of duplication error for Xcode. It has oneSettings.bundle
linked from project files and one copied by the plugin. Unfortunately, Xcode can't merge them automatically.As a workaround I added to my test project a script that manually copies the result files:
LicensePlist
here is a hardcoded name of the output folder. This script supports only single-paged acknowledgments. But it's not hard to support multiple copying.No Network Access
Another sandbox limitation is network connection restrictions. For GitHub packages,
LicensePlist
fetches licenses via GitHub API. Which is impossible to do in the sandbox. As a workaround, I used a path tocheckout
folder insideDerived Data
. During package resolving Xcode fetches the sources. Thus the tool can readLICENSE
files from disk instead of API calls.Changes
What's changed in the tool:
buildTool
parameter to let the plugin explicitly specify that the tool is used in a build tool mode,packageCheckoutPath
parameter with a path to package source codes,nameSpecified
).Future work
Binary Target
Makefile should be updated to support binary targets. I'm not sure that it's an Xcode bug. But currently, Xcode doesn't support executable targets for prebuild commands. As a workaround plugin uses downloaded binaries which I manually pushed to my repo.
SPM Command Plugin
I didn't have time for implementing a command plugin but I think it could be a helpful feature. Commands grant explicit write access. No need to have any scripts to copy result files. At the same moment, commands can't be called automatically. I'd prefer an automatic tool rather than a command in a context menu.
If @mono0926 thinks the path I chose is the right one I provide a pull request for this feature.
And I'd like to hear any comments regarding the implementation.
Beta Was this translation helpful? Give feedback.
All reactions