SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Multiple Targets and testing

Open Jon889 opened this issue 3 years ago • 1 comments

I have multiple targets in my project that are separate versions of the same application, and have SwiftLint in a build phase for each of them. However I also have a scheme that runs the unit tests for each target all at once, this is what runs on my CI. This means SwiftLint runs multiple times and there is a bit of weird behaviour with warnings not showing up every time.

Is there a way I can make sure SwiftLint only runs once when testing, but also will run for each target when building it normally?

Jon889 avatar Jun 16 '21 11:06 Jon889

I can think of a couple ways to address this:

  1. Don't run SwiftLint in CI as a build phase script (you can check for an environment variable that your CI provides). Then, run SwiftLint separately after compiling (from fastlane or a shell script, etc)
  2. Add an environment variable in your "run all" scheme and then check for it in each target's build phase. You'd probably need to figure out a way to run SwiftLint as part of your "run all" scheme though (maybe by using an Aggregate Target and adding it to your scheme)

marcelofabri avatar Jun 17 '21 18:06 marcelofabri