skip to Main Content

my swiftlint.yml file is not excluding my "Generated Mocks" folder. I’ve tried Generated Mocks and 'Generated Mocks' Is there a solution to this?

excluded:
  - Pods
  - MyProjectTests
  - MyProject/Helpers/Constants.swift
  - Generated Mocks

edit: The Generated Mocks folder was generated from a dependency I added so I hope that helps

2

Answers


    1. Instead of writing excluded commands in swiftlint.yml file, simply use included command and add your project path, tests etc. in here (paths where you want your swiftlint to run).

      For instance, my swiftlint.yml file looks like this:

    included:
     - [PROJECT_NAME]
     - [PROJECT_NAME]Tests
     - [PROJECT_NAME]UITests
    

    I only have a included command and I added paths where I want my swiftlint rules to work.

    1. Make sure to add this command:
    if which swiftlint >/dev/null; then
    swiftlint --config [PROJECT_PATH]/.swiftlint.yml
    else
      echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
    fi
    

    to:

    Target > Build Phases > Run Script

    1. And lastly, make sure that your .swiftlint.yml file is located of your project’s root path.

    Build the project, you’ll see that your SwiftLint warnings will show only for your included folders & files.

    Login or Signup to reply.
  1. Another approach would be to change the destination folder name from Genera†ed Mocks to GeneratedMocks, and then use this in .yaml (works for me):

    excluded:
    - Pods
    - UnitTests/generated/GeneratedMocks.swift
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search