-
Notifications
You must be signed in to change notification settings - Fork 319
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
Pin SwiftLint #4258
base: main
Are you sure you want to change the base?
Pin SwiftLint #4258
Conversation
…Tool Plug-in. Removes swiftlint.sh as it is no longer used.
…a Build Tool Plug-in. Removes swiftlint.sh as it is no longer used." This reverts commit dfea1ec.
scripts/swiftlint.sh
Outdated
echo "Warning: SwiftLint not installed in ${HOMEBREW_BINARY_DESTINATION}, download from https://github.com/realm/SwiftLint" | ||
fi | ||
|
||
swift package plugin swiftlint lint --quiet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running this in a Run Script Build Phase in Xcode doesn't work. I suspect it has to do with environment variables because I can reproduce it in the terminal if I source
the Xcode environment first. This is the error I get:
Invalid manifest (compiled with: [a-ton-of-options])
warning: using sysroot for 'iPhoneSimulator' but targeting 'MacOSX'
error: unable to load standard library for target 'arm64-apple-macosx13.0'
Happens on CI too, see here.
swift package plugin \ | ||
--allow-writing-to-directory fastlane/test_output/swiftlint \ | ||
swiftlint \ | ||
--strict \ | ||
--reporter junit \ | ||
--output fastlane/test_output/swiftlint/junit.xml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work because somehow swift package plugins run for every module. Only the last of those runs will save the output file, causing issues to be lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running it with verbose output tells me it's running for each module, which map to the targets specified in our Package.swift
:
info: Finished running in module 'RevenueCat_CustomEntitlementComputation'
info: Finished running in module 'RevenueCatUITests'
info: Finished running in module 'RevenueCatUI'
info: Finished running in module 'RevenueCat'
info: Finished running in module 'ReceiptParserTests'
info: Finished running in module 'ReceiptParser'
I think this is swift package
that's running the plugin
command for each target. It seems to be happening outside of swiftlint
's control. Not sure yet how to make swift package
confine itself to a single target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a convention to support a --target
argument. SwiftLint's command plugin supports it partly. It passes the --target
argument on to the actual swiftlint
program, which doesn't recognize it and errors out.
There’s a fork that fixes this issue. I’ve asked if they can propose their fix upstream.
scripts/swiftlint.sh
Outdated
echo "Warning: SwiftLint not installed in ${HOMEBREW_BINARY_DESTINATION}, download from https://github.com/realm/SwiftLint" | ||
fi | ||
|
||
swift package plugin swiftlint lint --quiet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks! Is there an advantage of using the absolute path to xcrun
? Isn't /usr/bin
usually part of the $PATH
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No advantage if it's already available via $PATH
.
Installs SwiftLint through SPM, and runs it as
This is a draft because of the problems linked above.