How to use Regex Builders in a cross platform mac/linux project

I'm working on building a tool that can run on both Linux machines (think github actions) as well as locally on a mac. I need to parse some regexes and I would like to use regex builders. I've created a basic Package.swift for the tool.

Sorry if it's already been posted here, but I wasn't sure how to get something like this working:

import RegexBuilder

struct SomeType {
  var a: Int
  var b: Int

                          // Xcode prompts me to add this locally, 
                          // but how do I include
                          // linux as a destination
@available(macOS 13.0, *) // <<<-------
extension SomeType {
  static func fromString(_ str: String) throws -> SomeType {
    let aRef = Reference(Int.self)
    let bRef = Reference(Int.self)
    let regex = Regex {
       // ...

    let match: Regex<_>.Match = ...
    return SomeType(a: match[aRef], b: match[bRef])

Do I need to specify something in the Package.swift to make this work to set a minimum version for mac and linux or is there some @available that will work for this?

Not at all sure, but this seems to be a Swift feature, more than a platform feature. Maybe it ought to be @available(swift 5.7, *) ?

That probably would work, but after a little more digging wasn't what fixed it. It seems like the supported platforms only specifies minimum deployment targets (SupportedPlatform: linux not allowed? - #2 by mickael). Adding in a target for macOS resolved the issue. This doesn't restrict the allowed platforms like I would have expected.

E.g. this was the change that I needed to add the platforms key:

let package = Package(
	name: "PackageName",
	platforms: [
1 Like