简体   繁体   English

从Swift Cocoa Touch Framework导入JWT

[英]import jwt from swift cocoa touch framework

I am working on swift cocoa touch framework to create reusable framework from mobile application. 我正在研究swift cocoa touch framework以从移动应用程序创建可重用框架。

my framework need to use jwt project from https://github.com/vapor/jwt.git 我的框架需要使用https://github.com/vapor/jwt.git jwt项目

i tried to create Package.swift and then add .package(url:"https://github.com/vapor/jwt.git", from: "3.0.0") and then run swift package resolve 我尝试创建Package.swift ,然后添加.package(url:"https://github.com/vapor/jwt.git", from: "3.0.0") ,然后运行swift package resolve

in my code, i import jwt library like this 在我的代码中,我像这样导入jwt库

import JWT
import Foundation

but i got the error No such module 'JWT' 但是我得到了错误No such module 'JWT'

i am newbie on swift, can someone help please? 我是新手,很快有人可以帮忙吗?

my Package.swift is here 我的Package.swift在这里

// 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"]),
    ]
)

You should check two things: 您应该检查两件事:

  1. Module name is JWT , not jwt . 模块名称是JWT而不是jwt
  2. Check that your .target in Package.swift contains "JWT" in dependencies 检查Package.swift中的.target是否包含"JWT" dependencies

thanks all guys for the feedback. 谢谢大家的反馈。

now i can solve the problem, and i write the solution to this blog 现在我可以解决问题了,我为此博客写了解决方案

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM