首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Swift包管理器-分发已存在的Cocoapod

Swift包管理器-分发已存在的Cocoapod
EN

Stack Overflow用户
提问于 2020-12-01 04:39:21
回答 1查看 415关注 0票数 1

我想让我已经存在的Cocoapods也可以作为Swift包使用。事情是这样的。我的一个pod依赖于另一个pod,所以我在我的Swift包中添加了以下内容:

代码语言:javascript
复制
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "Luminous",
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "Luminous",
            targets: ["Luminous"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(
            url: "https://github.com/andrealufino/Deviice.git",
            from: "1.30.2"
        )
    ],
    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.
        .target(
            name: "Luminous",
            dependencies: [],
            path: "Sources"),
        .testTarget(
            name: "LuminousTests",
            dependencies: ["Luminous"]),
    ]
)

我的另一个问题是:为什么在安装包时会包含Example文件夹?这是这张照片。

此外,最后一件事,当我在我的项目中添加了包时,它失败了,因为它找不到依赖的模块。错误是No such module Deviice

我想我添加了足够的细节,如果你需要更多,尽管问。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-01 16:47:29

我将回答有关找不到Deviice的问题。其他问题是关于本地路径的。

你可以看到你的包是这样的(在下一条评论中,“包”可以理解为库,但也可以理解为可执行文件,用于测试目的通常是“子包”或“真正的可执行文件”。

代码语言:javascript
复制
let package = Package(
    name: "Luminous",  // Name of your package
    products: [],      // What packages people will see relying on internal sub-packages
    dependencies: [],  // External packages you relies on
    targets: []        // Internal "sub-packages", etc.
)

每个target都有一个dependencies: [],您可以在其中放置其他目标的名称(它是“内部”的,或者是您之前在dependencies[]中声明的公共目标。

代码语言:javascript
复制
.target(
        name: "Luminous",
        dependencies: [], //Put here names of either sub packages OR public package you "called before"
        path: "Sources")

在您的案例中:

代码语言:javascript
复制
.target(
        name: "Luminous",
        dependencies: ["Deviice"],
        path: "Sources")

确实是你自己写的:

代码语言:javascript
复制
.testTarget(
            name: "LuminousTests",
            dependencies: ["Luminous"])

所以你说它依赖于“发光”子包,这里的逻辑与Deviice相同。

您可以使用Package of Alamofire+Image作为示例。它使用作为外部依赖项的Alamofire,并将其放在原处。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65080854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档