使用Swift Package Manager添加目标依赖项时出错

时间:2023-01-23 23:48:50

When trying to include a target dependency I get the error: The manifest describes a target that cannot be found in your source tree: parser

尝试包含目标依赖项时,我收到错误:清单描述了在源树中找不到的目标:解析器

Here is my Package.swift file:

这是我的Package.swift文件:

import PackageDescription

let package = Package(
    name: "Phoenix",
          targets: [
            Target(
                name: "Phoenix",
                dependencies: [.Target(name: "parser")]),
            Target(
                name: "parser")
    ]
)

I am following the format described here: https://github.com/apple/swift-package-manager/blob/master/Documentation/Package.swift.md

我遵循这里描述的格式:https://github.com/apple/swift-package-manager/blob/master/Documentation/Package.swift.md

3 个解决方案

#1


5  

Do you have a parser directory?

你有一个解析器目录吗?

You should have a layout something like:

你应该有一个类似的布局:

     .
     └── Sources
         └── Phoenix
         │   └── File1.swift
         └── parser
             └── File2.swift

Or:

     .
     └── Phoenix
     │   └── File1.swift
     └── parser
         └── File2.swift

This instructs SwiftPM to create two modules, one called Phoenix and one called "parser".

这指示SwiftPM创建两个模块,一个名为Phoenix,另一个名为“parser”。

#2


2  

While you're both right, my actual problem was that my subdirectory didn't contain any swift code so a module wasn't being generated

虽然你是对的,但我的实际问题是我的子目录没有包含任何swift代码,因此没有生成模块

#3


0  

The Swift Package Manager documentation you link to states The targets are named how your subdirectories are named. If the target parser cannot be found, presumably you do not have a subdirectory named parser located in the directory where your Package.swift file is located.

链接到状态的Swift包管理器文档目标命名为子目录的命名方式。如果找不到目标解析器,可能是您的Package.swift文件所在的目录中没有名为parser的子目录。

You should clarify your directory structure so that it can be compared to your Package.swift contents.

您应该阐明您的目录结构,以便可以将其与Package.swift内容进行比较。

Edit

Max has provided a good example. Note that the 'Sources' dir could also be 'Source', 'src' or 'srcs'

马克斯提供了一个很好的例子。请注意,'来源'目录也可能是'来源','src'或'srcs'

#1


5  

Do you have a parser directory?

你有一个解析器目录吗?

You should have a layout something like:

你应该有一个类似的布局:

     .
     └── Sources
         └── Phoenix
         │   └── File1.swift
         └── parser
             └── File2.swift

Or:

     .
     └── Phoenix
     │   └── File1.swift
     └── parser
         └── File2.swift

This instructs SwiftPM to create two modules, one called Phoenix and one called "parser".

这指示SwiftPM创建两个模块,一个名为Phoenix,另一个名为“parser”。

#2


2  

While you're both right, my actual problem was that my subdirectory didn't contain any swift code so a module wasn't being generated

虽然你是对的,但我的实际问题是我的子目录没有包含任何swift代码,因此没有生成模块

#3


0  

The Swift Package Manager documentation you link to states The targets are named how your subdirectories are named. If the target parser cannot be found, presumably you do not have a subdirectory named parser located in the directory where your Package.swift file is located.

链接到状态的Swift包管理器文档目标命名为子目录的命名方式。如果找不到目标解析器,可能是您的Package.swift文件所在的目录中没有名为parser的子目录。

You should clarify your directory structure so that it can be compared to your Package.swift contents.

您应该阐明您的目录结构,以便可以将其与Package.swift内容进行比较。

Edit

Max has provided a good example. Note that the 'Sources' dir could also be 'Source', 'src' or 'srcs'

马克斯提供了一个很好的例子。请注意,'来源'目录也可能是'来源','src'或'srcs'