swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.13k stars 102 forks source link

How to use other SPM packages in Swift lambda function? #172

Closed IuriiIaremenko closed 3 years ago

IuriiIaremenko commented 3 years ago

Expected behavior

I just want to use some code from other SPM packages, for example, I want to include SwiftJWT

import AWSLambdaRuntime
import SwiftJWT

Lambda.run { (context, name: String, callback: @escaping (Result<String, Error>) -> Void) in
/// some code that are using SwiftJWT
}

I added a dependency:

import PackageDescription

let package = Package(
    name: "ThePushLambda",
    products: [
        .executable(name: "ThePushLambda", targets: ["ThePushLambda"]),
    ],
    dependencies: [
        .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "0.1.0"),
        .package(url: "https://github.com/IBM-Swift/Swift-JWT.git", from: "3.6.1"),
    ],
    targets: [
        .target(
            name: "ThePushLambda",
            dependencies: [
                .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
                .product(name: "AWSLambdaEvents", package: "swift-aws-lambda-runtime"),
                "SwiftJWT" // <--- After adding this line target becomes missing in the Xcode.
            ])
    ]
)

Actual behavior

After adding SwiftJWT dependency into the target dependencies list, the target becomes invalid in the Xcode.

Is it possible to use SPM packages other than swift-aws-lambda-runtime ?

IuriiIaremenko commented 3 years ago

Nevermind, it's SwiftJWT issue.