Swift 5.10 fail to recognize regex litgeral in command line

I create a simple project with "swift package init".
It failed to compile with "swift build". It seems that the compiler does not recognize the regex literal at all:

I also tried with "$(xcrun --find swift) build" but got the same error
What did I missed?

Make sure to build for at least macOS 13. That’s platforms: [.macOS(.v13)] in Package.swift.

If I remember correctly, the bare slash literals are an upcoming feature that needs to be manually enabled in your Package.swift manifest (or Xcode build settings) for now.

In your target's swiftSettings, you might need to add ```

1 Like

Thanks @tkrajacic and @SimplyDanny .
Add the configurations you mentioned. Following Package.swift works like a charm!

import PackageDescription

let package = Package(
    name: "LearningSwift",
    platforms: [
    targets: [
        // Targets are the basic building blocks of a package, defining a module or a test suite.
        // Targets can depend on other targets in this package and products from dependencies.
        .executableTarget(name: "LearningSwift", swiftSettings: [.enableUpcomingFeature("BareSlashRegexLiterals")])
1 Like