SwiftLint
SwiftLint copied to clipboard
Multiple Targets and testing
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?
I can think of a couple ways to address this:
- 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) - 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)