Reputation: 211
I tried to install SwiftLint using CocoaPods and I add in Build phases the following script :
"${PODS_ROOT}/SwiftLint/swiftlint"
SwiftLint is installed correctly and I get many errors and warnings in the project.
Then, I create the swiftLint.yml file in which I modify some rules but they are not token into consideration and the same number of errors and warnings persist in Xcode project.
When I run this command to confirm the application of the rules :
./swiftlint lint --config .swiftlint.yml
I get the error :
No lintable files found at paths : ''
How can I solve this issue please?
Upvotes: 17
Views: 19743
Reputation: 394
One of the reasons for this error is directory of the .swiftlint.yml file. If you locate it wrong, then it may not work as expected. If your swiftlint file is in the parent folder, then you should specify it with ../ prefix,
--config ${SRCROOT}/../.swiftlint.yml
The next point is the directory of included files. In .swiftlint.yml file, included files' directory might be wrong if you specify included and excluded files.
Upvotes: 0
Reputation: 354
This code is useful for those who use SwiftLint using cocoa pods.
Add the below line in the Run script.
1.
"${PODS_ROOT}/SwiftLint/swiftlint"
If you get the error again, use the below script.
2.
"${PODS_ROOT}/SwiftLint/swiftlint" --config "${SRCROOT}/.swiftlint.yml"
After a spend long time to find error like
Error: No lintable files found at paths: ''
The above 2nd script works for me.
Upvotes: 0
Reputation: 991
Replace autocorrect
with --fix
export PATH="$PATH:/opt/homebrew/bin"
if which swiftlint > /dev/null; then
swiftlint --fix && swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
Upvotes: 3
Reputation: 1252
For M1, don't go for swift lint installation VIA PODS instead use Brew. For installation run below command in Terminal
brew install swiftlint
and add below scripts into RunScript into build phase of your target.
export PATH="$PATH:/opt/homebrew/bin"
if which swiftlint > /dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
Upvotes: 0
Reputation: 1
This worked for me
if which "${PODS_ROOT}/SwiftLint/swiftlint" >/dev/null; then
${PODS_ROOT}/SwiftLint/swiftlint --fix && ${PODS_ROOT}/SwiftLint/swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
Upvotes: -2
Reputation: 112
If you using pod file then follow this steps:
Run Script: "${PODS_ROOT}/SwiftLint/swiftlint"
Upvotes: -2
Reputation: 419
For those of you who used 0.42.0 before and updated to 0.43.0 (or higher?).
They made a change and now interpret included
and excluded
as relative paths.
Configuration files now consistently have their included/excluded relative file paths applied relative to their location in the file system. Previously the root configuration file applied these relative to the current working directory, but nested configurations applied these to their location in the file system.
From the release notes of 0.43.0: Clothes Line Interface.
Upvotes: 3
Reputation: 1612
If you installed it using Cocoapods this can help you. I will just merely improve the above answers, to put clarity on how to resolve the issue of SwiftLint not finding the path.
Things to lookout for.
In your script.
"${PODS_ROOT}/SwiftLint/swiftlint" --path "${SRCROOT}/Classes" --config "directory-of-your-config"
The --path param should be your own --path "${SRCROOT}/Classes"
Finally inside the yml file.
Make sure your included and excluded file specification is correct, see how I did mine below.
included:
- Your-Project-Name
excluded:
- Pods
One Important thing to note is if you add directories under included: the --path param will be ignored, and you might possibly get the "no lintable files found" error if the directory is wrong.
Upvotes: 4
Reputation: 3245
It happens also if you rename the directory of your app, make sure you report the change in the .swiftlint.yml too at first lines :
included: # paths to include during linting
- My_App_Directory
Upvotes: 14
Reputation: 1736
For swiftlint from version 0.41 the following code worked for me in the build phase (workspace with several projects. Depending on the project configuration, it may be that "../" has to be removed from the path information):
cd ${PROJECT_DIR}/../
"${PODS_ROOT}/SwiftLint/swiftlint" --config "${PROJECT_DIR}/../.swiftlint.yml"
Here is a screenshot of the build phase entry:
Upvotes: 1
Reputation: 61
if you are using swiftLint with CocoaPods : try "${PODS_ROOT}/SwiftLint/swiftlint" --config .swiflint.yml
in your SwiftLint Run Script in your project build phases.
make sure your .swiflint.yml config file is in the root of your project directory ( beside .xcodeproj file ).
make sure the paths included on your .swiflint.yml (in included: and excluded: sections ) is valid paths
make sure your .swiflint.yml file is valid yaml
don't escape the directory paths in your config file
dont do : - some\ Directory
but do - some Directory
without escape character.
Upvotes: 2
Reputation: 40247
First of all, you do not need to add explicitly the--config
file if the yml
file is in the running directory (from where you are running the command) and name is .swiftlint.yml
.
Secondly, you need to specify the path for your source with --path
. Below command will work fine in your case,
swiftlint lint --path SourcePath
Upvotes: 3