我的新Swift项目不是用最新版本的Antlr4构建的。
我以前创建过类似的项目(使用Antlr 4.10(,但我只遇到Antlr 4.11和4.11.1的问题。我得到以下错误
https://github.com/antlr/antlr4 @ 4.11.1: error: /Package.swift has no Package.swift manifest for version 4.11.1 in https://github.com/antlr/antlr4
下面是我的Package.swift文件
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "spl-swift",
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
//.package(url: "/private/tmp/Antlr4-tmp-1663142993", from: "4.0.0")
.package(url: "https://github.com/antlr/antlr4", from: "4.11.1")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.executableTarget(
name: "spl-swift",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"Antlr4"
]),
.testTarget(
name: "spl-swiftTests",
dependencies: ["spl-swift"]),
]
)
我不知道为什么4.11.1会出现这个问题,但我下载了4.10.1版本并将其用作本地依赖,从而使其正常工作
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "spl-swift",
dependencies: [
.package(name: "Antlr4", path: "~/Downloads/antlr4-4.10.1"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
//.package(url: "https://github.com/antlr/antlr4", from: "4.11.1")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.executableTarget(
name: "spl-swift",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"Antlr4"
],
exclude: [
"Lang.tokens",
"LangLexer.interp",
"LangLexer.tokens",
"Lang.interp"
]),
.testTarget(
name: "spl-swiftTests",
dependencies: ["spl-swift"]),
]
)