SPM Plugin with binary target high CPU Usage

Hey there,

I was just about to add a SPM build tool plugin to my project.
After adding the dependency of the plugin to my Package.swift file, Xcode started getting really slow. A quick look in the Activity monitor showed that Xcode has a massive cpu usage (100% or higher).
I've also noticed that the swift package seems to resolve the plugin dependency again and again (especially the binary target the dependency contained). Removing the dependency from the Package file brings the cpu back to a normal load.
Is this a known bug or is there something I can do against it?

Adding a plugin without a binary target works just fine. And as a side note, I've tried this with Xcode 13.4.1 (tools version 5.6) and 14.0 beta 3 (tools version 5.7). It seems its only an issue with the checkout, since adding a local plugin to my package with a binary target also works without problems.


I have the same issue with an executableTarget and GitHub - lukepistrol/SwiftLintPlugin: A Swift Package Plugin for SwiftLint and or GitHub - MarcoEidinger/SwiftFormatPlugin: Swift Package (Command) Plugin to format source code with nicklockwood/SwiftFormat. I disabled the plugins for now as text editing in Xcode becomes too slow.

I have invested some more time to debug this issue. For me, I was able to bypass it by including the .artifactbundle into the Git repo of the plugin by using

    name: "mytool",
    path: "mytool.artifactbundle.zip"

in the Package.swift file. While using a binary target URL, the Xcode Inspectors also start flickering if I have the Package.swift file of my plugin open. Referenced Binaries appear and disappear a couple of times every second. Those issues are solved when specifying a local file path. I don't consider this a good workaround though as my plugin binary is a little bit larger and I don't want to have them in the Git history.

1 Like

This resolved the CPU usage for me. Hopefully in the future including the artifact in the git repo won't be necessary.