Unable to use SwiftLint with Swift Package Manager
Environment
- SwiftLint version: 0.47.0
- Installation method: Swift Package
- Xcode version: 13.2.1
- Deployment Target: iOS 14.1
Bug description
I am trying to Migrate my existing project to "Swift Package Manager" from "Cocoapods"
The project with Cocoapods is working fine. But, When I try to build my current project with "Swift Package Manager", I am getting following error for SwiftLint. I don't have any issues with other swift packages.

I tried by deleting Derived data. Then I am getting this issue Then, I quit and launch the Xcode, I am getting the above error(as shown in the image)
Before(While using Cocoapods), I am using following as Run Script in Build Phases
if which ${PODS_ROOT}/SwiftLint/swiftlint >/dev/null; then
${PODS_ROOT}/SwiftLint/swiftlint --strict
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
Now(While using Swift Package), I am using following as Run Script in Build Phases
if swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
What's your Package.swift? Based on the Xcode error messages, it's telling you Xcode is trying to build SwiftLint to run on an iOS target, which it of course won't work, considering SourceKit is only available on macOS and Linux.
I don't have any Package.swift file. Will it create automatically? How can we get it?
I added Packages under "Package Dependencies" tab.
That won't work, that'll try to build a target with the SwiftLint macOS binary for an iOS target, which won't work for the reasons I explained above.
I'm also getting errors:

You're using SwiftLint as a build dependency but I believe you're only looking to lint the code. In that case, you shouldn't add SwiftLint as a pod or SPM dependency. Instead, install SwiftLint through Brew and make sure your build phases contain a step for running SwiftLint
Thank you for the nonpatronizing response and solution, @Ferdzz.
I think enough advice has been provided. Closing the issue for now.