1

Is there a way in Xcode to share a run script build phase across multiple projects in a workspace?

I am using SwiftLint to enforce coding styles, but I don't want to manually add the necessary run script to all of the projects (that I maintain, not 3rd party) in my Xcode project.

Adam Johns
  • 35,397
  • 25
  • 123
  • 176

1 Answers1

2

I found a solution, but it is a solution specific to SwiftLint, not any run script.

My solution that seems to work fine is to pick whichever target I will normally be building and only put the run script for that target, but make the run script specify the --path to be one directory up. Since SwiftLint runs recursively in all subdirectories this works fine:

swiftlint lint --path "$SRCROOT"/..

Adam Johns
  • 35,397
  • 25
  • 123
  • 176