swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
https://swiftpackageindex.com/swift-server/swift-aws-lambda-runtime
Apache License 2.0
1.15k stars 104 forks source link

Support as a dependency of an (existing) iOS app #134

Closed JuliusBahr closed 4 years ago

JuliusBahr commented 4 years ago

Expected behavior

I tried to include the runtime into my existing Xcode iOS app through the SPM UI of Xcode. I expected this to work, so I can dispatch lambda functions from my iOS app.

Actual behavior

In the Package.swift of your project: let package = Package( name: "swift-aws-lambda-runtime", platforms: [ .macOS(.v10_13), ]

so iOS is not supported.

Steps to reproduce

Integrate into iOS app through Xcode SPM.

If possible, minimal yet complete reproducer code (or URL to code)

SwiftAWSLambdaRuntime version/commit hash

0.2.0

Swift & OS version (output of swift --version && uname -a)

Xcode 11.5

tomerd commented 4 years ago

Hi @JuliusBahr

The library is designed to help build Lambda functions that can then be run on AWS Lambda. An iOS application can then invoke Lambda functions using HTTP calls (with URLSession for example) if the Lambda function is exposed through API Gateway, or directly using one of the AWS SDKs for iOS.

In other words, this library helps build the server[less] side, while the iOS application is the client, and the interaction between the client and the server can be done over simple HTTP calls (if Lambda is exposed this way) or managed one with an AWS SDK.

JuliusBahr commented 4 years ago

Thanks for the explanation. I guess I will checkout out the WWDC session on it this week.

adam-fowler commented 4 years ago

@JuliusBahr you can use AWSSDKSwift to dispatch Lambda functions.

import Lambda

let lambda = Lambda(region: .euwest1)
let request = Lambda.InvocationRequest(functionName: "Hello", payload: .string("{\"name\": \"world\"}"))
let response = try lambda.invoke(request).wait()