Swift包管理器- Swift 4语法

时间:2023-01-24 00:26:01

I'm trying to use updated SPM for Swift4 with the following Package.swift file - PackageDescription API Version 4

我正在尝试使用更新的SPM为Swift4与以下包。swift文件- PackageDescription API版本4

import PackageDescription

let package = Package(
    name: "Name",
    dependencies : [
        .package(url: "url", .branch("swift4"))
    ],
    exclude: ["Tests"]
)

I have a correct version of SPM also:

我有一个正确的SPM版本:

Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13081.9)

Apple Swift包管理器- Swift 4.0 -dev (swiftpm-13081.9)

But I can not build the library by swift build command. I see the following error:

但是我不能通过swift构建命令来构建库。我看到以下错误:

... error: type 'Version' has no member 'branch'

…错误:类型“版本”没有成员“分支”

1 个解决方案

#1


17  

You're missing the tools version specifier in your manifest; add the following as the first line of your Package.swift:

您在清单中缺少工具版本说明符;添加以下内容作为您的第一行。

// swift-tools-version:4.0

By default if that line is omitted, it'll default to manifest version 3 and also compiler version 3. For more information see SE-0152 or Swift Package Manager Manifest API Redesign on swift.org.

默认情况下,如果省略了这一行,它将默认显示版本3和编译器版本3。有关更多信息,请参见Swift .org上的SE-0152或Swift包管理器Manifest API重新设计。

#1


17  

You're missing the tools version specifier in your manifest; add the following as the first line of your Package.swift:

您在清单中缺少工具版本说明符;添加以下内容作为您的第一行。

// swift-tools-version:4.0

By default if that line is omitted, it'll default to manifest version 3 and also compiler version 3. For more information see SE-0152 or Swift Package Manager Manifest API Redesign on swift.org.

默认情况下,如果省略了这一行,它将默认显示版本3和编译器版本3。有关更多信息,请参见Swift .org上的SE-0152或Swift包管理器Manifest API重新设计。