motivation: consisten naming convention changes: * Lambda.InitializationContext -> LambdaInitializationContext * Lambda.Runner -> LambdaRunner * Lambda.Configuration -> LambdaConfiguration * Lambda.RuntimeError -> LambdaRuntimeError * adjust call sites, tests, and examples
Local Debugging Example
This sample project demonstrates how to write a simple Lambda function in Swift, and how to use local debugging techniques that simulate how the Lambda function would be invoked by the AWS Lambda Runtime engine.
The example includes an Xcode workspace with three modules:
- MyApp is a SwiftUI iOS application that calls the Lambda function.
- MyLambda is a SwiftPM executable package for the Lambda function.
- Shared is a SwiftPM library package used for shared code between the iOS application and the Lambda function, such as the Request and Response model objects.
The local debugging experience is achieved by running the Lambda function in the context of the debug-only local lambda engine simulator which starts a local HTTP server enabling the communication between the iOS application and the Lambda function over HTTP.
To try out this example, open the workspace in Xcode and "run" the two targets,
using the relevant MyLambda and MyApp Xcode schemes.
Start with running the MyLambda target.
- Switch to the
MyLambdascheme and select the "My Mac" destination - Set the
LOCAL_LAMBDA_SERVER_ENABLEDenvironment variable totrueby editing theMyLambdascheme Run/Arguments options. - Hit
Run - Once it is up you should see a log message in the Xcode console saying
LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invokewhich means the local emulator is up and receiving traffic on port7000and expecting events on the/invokeendpoint.
Continue to run the MyApp target
- Switch to the
MyAppscheme and select a simulator destination. - Hit
Run - Once up, the application's UI should appear in the simulator allowing you to interact with it.
Once both targets are running, set up breakpoints in the iOS application or Lambda function to observe the system behavior.