Skip to content

FormatPlugin and LintPlugin are not BuildToolPlugin. #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
qxiang opened this issue Apr 12, 2023 · 11 comments
Open

FormatPlugin and LintPlugin are not BuildToolPlugin. #511

qxiang opened this issue Apr 12, 2023 · 11 comments

Comments

@qxiang
Copy link

qxiang commented Apr 12, 2023

Most formatting and linting tasks happen at build time and Xcode has support for build time plugins if they conform to BuildToolPlugin. Therefore, maybe we should consider making FormatPlugin and LintPlugin BuildToolPlugin? This will make it easier to integrate swift-format for people who use Xcode.

@allevato
Copy link
Member

There is some previous discussion of this in this pull request.

@tonyarnold
Copy link

tonyarnold commented May 13, 2023

@allevato is there interest in this? I'd be happy to pick up adding build plugins, but it would probably necessitate hosting pre-built binaries and including them via binaryTarget (assuming these plugins were to be created as pre-build commands).

@tskippervold
Copy link

@tonyarnold I think it would be a very nice addition to be able to either lint or format the code during the build phase.

@macshome
Copy link
Contributor

macshome commented Aug 2, 2023

I'm happy to help out with this. I had closed #489 as it felt as if we needed the larger solution of making things into build plugins.

@ylorn
Copy link

ylorn commented Oct 17, 2023

Any updates on this? It will really handy to have the lint warnings while building.

@BrentMifsud
Copy link

Any updates here?

SwiftLint has become very bloated. It would be nice to finally be able to use the official linter/formatter

@BrentMifsud
Copy link

I attempted this here #690 but without a hosted binary, the build plugins cannot be run.

@ahoppen
Copy link
Member

ahoppen commented Apr 23, 2024

Tracked in Apple’s issue tracker as rdar://126948335

@BrentMifsud
Copy link

is there any movement on this?

@BrentMifsud
Copy link

BrentMifsud commented Apr 12, 2025

Just my yearly checkup on this issue.

Is there any chance of this ever coming? Is there a reason there is so little movement here? Is it a limitation of SPM? Im just curious. Because SwiftLint has had this available for quite some time.

EDIT: I noticed that this tool is now included with the swift toolchain. That's huge.

Does anyone know if there is a way to get this running when working on swift packages? As far as I am aware, you can only run pre-build scripts for Xcode app projects.

@tonyarnold
Copy link

It works fine with Swift Packages - there's no such limitation around pre-build commands.

Here, use this as your plugin, and it should work just fine: https://gist.github.com/tonyarnold/9ce276cb6cd3c0e4933c070e1ab5ecac

I found Xcode would not show the warnings in the navigator for Xcode targets, but they show up in the build logs, and within the sources you're working with.

Swift Packages worked great - everything showed up where it should, including in the navigator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants