Xcode Run Scripts and Swift Package Manager

I know that Run Scripts currently can't be set up, via Scheme or otherwise, for Swift Packages. What I'm wondering is what the preferred workaround / project structure is for setting this up that's lightest or makes the most sense?

I've tried adding an .xcodeproj that references the Package.swift directly, with an empty target that builds no files and fires off the script. This feels awful to me. How is everyone else handling this? Just running via command line for now?

Additionally, I can't find the Run Script ticket to track anymore. Has the proposal died? I'm really hoping to get an idea of when this will be implemented. Very painful trying to get SwiftLint warnings in Xcode with Swift Packages.

6 Likes

I came up with a solution that involves having a .xcworkspace as well as a "RunScriptHelper.xcodeproj" in the root, which is entirely empty, but has two run scripts:

  1. Generates an empty Info.plist (so this file doesn't ever need to be checked in).
  2. Run swiftlint or whatever else I need.

It's not great, but at least it's only adding two files to my project. Everything else runs through SPM properly.

It's a decent workaround for now, but if anyone has any better ideas, I'm very, very interested in something better.

3 Likes