代码之家  ›  专栏  ›  技术社区  ›  Alongkorn

从Swift Cocoa Touch框架导入JWT

  •  0
  • Alongkorn  · 技术社区  · 7 年前

    我正在工作 swift cocoa touch framework 从移动应用程序创建可重用框架。

    我的框架需要使用 jwt 项目从 https://github.com/vapor/jwt.git

    我试图创造 Package.swift 然后添加 .package(url:"https://github.com/vapor/jwt.git", from: "3.0.0") 然后运行 swift package resolve

    在我的代码中,我像这样导入JWT库

    import JWT
    import Foundation
    

    但我搞错了 No such module 'JWT'

    我是斯威夫特的新手,有人能帮忙吗?

    我的包裹.斯威夫特在这儿

    // swift-tools-version:4.2
    // The swift-tools-version declares the minimum version of Swift required to build this package.
    
    import PackageDescription
    
    let package = Package(
        name: "edoc-sdk-swift",
        products: [
            // Products define the executables and libraries produced by a package, and make them visible to other packages.
            .library(
                name: "edoc-sdk-swift",
                targets: ["edoc-sdk-swift"]),
        ],
        dependencies: [
            .package(url:"https://github.com/vapor/jwt.git", from: "3.0.0")
        ],
        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 which this package depends on.
            .target(
                name: "edoc-sdk-swift",
                dependencies: ["JWT"]),
            .testTarget(
                name: "edoc-sdk-swiftTests",
                dependencies: ["edoc-sdk-swift"]),
        ]
    )
    
    2 回复  |  直到 7 年前
        1
  •  0
  •   user28434'mstep    7 年前

    你应该检查两件事:

    1. 模块名称为 JWT , not jwt .
    2. 检查一下你的 .target 在里面 Package.swift 包含 "JWT" 在里面 dependencies
        2
  •  0
  •   Alongkorn    7 年前

    谢谢大家的反馈。

    现在我可以解决这个问题了,我把解决方案写在这个博客上

    https://piggyman007.blogspot.com/2018/12/create-swift-framework-and-include-some.html