Skip to content
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

SPM can't find swiftlint in build products dir #5032

Closed
2 tasks done
marchinram opened this issue May 24, 2023 · 8 comments
Closed
2 tasks done

SPM can't find swiftlint in build products dir #5032

marchinram opened this issue May 24, 2023 · 8 comments
Labels
integration Issues related to integration of SwiftLint into toolchains.

Comments

@marchinram
Copy link

New Issue Checklist

Describe the bug

After adding SwiftLint to my project following these directions (I didn't link against the executable & framework products) the SwiftLint plugin cannot appear to find the executable, it assumes its at /${BUILD_DIR}/${CONFIGURATION}/swiftlint, I also have swiftlint installed via homebrew but the plugin isn't looking in /usr/local/bin/swiftlint

Complete output when running SwiftLint, including the stack trace and command used

Xcode build output when plugin is run on build (with directory names changed)

/usr/bin/sandbox-exec -p "(version 1)
(deny default)
(import \"system.sb\")
(allow file-read*)
(allow process*)
(allow file-write*
    (subpath \"/private/tmp\")
    (subpath \"/private/var/folders/zm/t882rxjn0m1b_vt35vzl3kym0000gn/T\")
)
(deny file-write*
    (subpath \"/src/to/app\")
)
(allow file-write*
    (subpath \"/derived/data/path/SourcePackages/plugins/playground.output/Playground/SwiftLintPlugin\")
)
" "/${BUILD_DIR}/${CONFIGURATION}/swiftlint" lint --quiet --force-exclude --cache-path /derived/data/path/SourcePackages/plugins/playground.output/Playground/SwiftLintPlugin /src/to/app/MyApp.swift

The file “swiftlint” doesn’t exist.

Environment

  • 0.52.2
  • SPM
  • Xcode 14.2
  • Build version 14C18
@mason-livefront
Copy link

I am seeing the same issue.

@revolter
Copy link
Contributor

revolter commented Jun 5, 2023

I tried a workaround by adding a Run Script build phase with the content

ln -fs "${BUILD_DIR}/../../SourcePackages/artifacts/swiftlint/SwiftLintBinary.artifactbundle/swiftlint-0.52.2-macos/bin/swiftlint" "/${BUILD_DIR}/${CONFIGURATION}/swiftlint"

and even though I couldn't move it before the Run Build Tool Plug-ins build phase, I hoped that a second run would work, but it didn't.

I checked that the symbolic link gets created, and that it gets created at the correct path, and even successfully executed it from the terminal, but it most probably doesn't work because of the /usr/bin/sandbox-exec part.

@sfoulston
Copy link

sfoulston commented Jun 20, 2023

I saw this issue on Xcode 14.2 as well, but not when running on Xcode 14.3.1 (using SwiftLint 0.52.2).

However, on Xcode 14.3.1 there are severe performance issues, taking around 15 minutes to run in our project. It looked like this PR (a result of this issue) had resolved that, but it seems there could be an issue with Xcode itself that causes the plug-in to take an inordinately long time to run in larger projects (ours has 18 targets).

Does Xcode 14.3.1 resolve the issue of the binary being missing for you as well?

@wtpalexander
Copy link

Works on Xcode 14.3 but not Xcode 14.2 for me.

@jpsim
Copy link
Collaborator

jpsim commented Jun 20, 2023

Thanks for filing an issue here. SwiftLint's SwiftPM plugin integration is outside my area of expertise, maybe @technocidal or @tonyarnold could shed some light on what may be happening here?

@tonyarnold
Copy link
Contributor

Apologies for the delay in replying, folks.

Honestly, this appears to be an issue internal to Xcode. I'm not sure there's much that we can do from outside of Apple beyond some of the beautiful, terrifying build phase hacks (or scheme build pre-actions) for releases of Xcode prior to version 14.3.

I would suggest opening Feedback with Apple as a first step, but I'd imagine they're going to ask you to try to update to Xcode 14.3 or newer.

@SimplyDanny SimplyDanny added the integration Issues related to integration of SwiftLint into toolchains. label Jun 24, 2023
@marchinram
Copy link
Author

I'll try with Xcode 14.3 today and close if it works ok

@marchinram
Copy link
Author

Works for me now in 14.3, thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration Issues related to integration of SwiftLint into toolchains.
Projects
None yet
Development

No branches or pull requests

8 participants