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

SwiftLintPlugin execution from Script Build Phase #5677

Merged
merged 14 commits into from
Jul 21, 2024
Merged

SwiftLintPlugin execution from Script Build Phase #5677

merged 14 commits into from
Jul 21, 2024

Conversation

frankois944
Copy link
Contributor

@frankois944 frankois944 commented Jul 17, 2024

When using the plugin from SPM, it's possible to run the switlint binary directly in the Script Build Phase, just like any other command.
The script locates the binary path and executes the command.

Sound like the CocoaPods integration.

I just added the script in the README and using the default value (xcode 15/16), these values can be wrong in previous xcode version or with custom package path.

SWIFT_PACKAGE_DIR="${BUILD_DIR%Build/*}SourcePackages/artifacts"
SWIFTLINT_CMD=$SWIFT_PACKAGE_DIR/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-*/bin/swiftlint

if test -f $SWIFTLINT_CMD 2>&1
then
    $SWIFTLINT_CMD
else
    echo "warning: `swiftlint` command not found - See https://github.com/realm/SwiftLint#installation for installation instructions."
fi

When using the plugin, it's possible to run the command directly in the Script Build Phase, just like any other command
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An interesting and nifty way to get to a versioned binary. 👍

However, it's probably not sure if this will work with future Xcode versions. Perhaps, we should also add a warning that this approach might fail with changes in Xcode.

Co-authored-by: Danny Mösch <[email protected]>
@frankois944
Copy link
Contributor Author

However, it's probably not sure if this will work with future Xcode versions. Perhaps, we should also add a warning that this approach might fail with changes in Xcode.

Yes, I know, it's possible, if Xcode change again the project package path, but for now, it's working on the version 15 and 16.

We can replace this static path by a command to automatically find the binary, but i'm not a fan to execute it every time...

@SimplyDanny
Copy link
Collaborator

However, it's probably not sure if this will work with future Xcode versions. Perhaps, we should also add a warning that this approach might fail with changes in Xcode.

Yes, I know, it's possible, if Xcode change again the project package path, but for now, it's working on the version 15 and 16.

We can replace this static path by a command to automatically find the binary, but i'm not a fan to execute it every time...

Well, then we should mention exactly that: works in Xcode 15 and 16, but no guarantee for other versions or an alternative path.

frankois944 and others added 5 commits July 21, 2024 08:41
Co-authored-by: Danny Mösch <[email protected]>
Co-authored-by: Danny Mösch <[email protected]>
add warnings about the values of package path
update warn about default package path
@frankois944
Copy link
Contributor Author

frankois944 commented Jul 21, 2024

However, it's probably not sure if this will work with future Xcode versions. Perhaps, we should also add a warning that this approach might fail with changes in Xcode.

Yes, I know, it's possible, if Xcode change again the project package path, but for now, it's working on the version 15 and 16.
We can replace this static path by a command to automatically find the binary, but i'm not a fan to execute it every time...

Well, then we should mention exactly that: works in Xcode 15 and 16, but no guarantee for other versions or an alternative path.

Ok, I added this message.

The SWIFTLINT_CMD path use the default Xcode configuration and has been tested on Xcode 15/16, in case of another configuration like custom Swift package path, please change the values accordinaly.

Understand, I'm using the default Xcode values. The user must adapt his configuration.

Co-authored-by: Danny Mösch <[email protected]>
@SimplyDanny SimplyDanny enabled auto-merge (squash) July 21, 2024 11:31
@SimplyDanny SimplyDanny merged commit ffed455 into realm:main Jul 21, 2024
12 checks passed
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

Successfully merging this pull request may close these issues.

2 participants