swift-aws-lambda-runtime
swift-aws-lambda-runtime copied to clipboard
Add support for SPM Resources
Expected behavior
Hello!
We're looking to utilize PhoneNumberKit which packages Google's libphonenumber metadata for phone number validation.
When archiving the project using the built-in AWSLambdaPackager plugin, the project successfully compiles and generates the .zip to upload to AWS. Given that PhoneNumberKit declares the Google libphonenumber metadata as a resource for the target, it's expected that AWSLambdaPackager would include the resource in the generated .zip file.
For reference, the swift-lambda project added support for SPM resources with this commit: https://github.com/SwiftXcode/swift-lambda/commit/dac42bc867319cfe7d48fd4f39f12a6468c0274c
Actual behavior
The AWSLambdaPackager plugin does not include SPM resources in the .zip and at runtime, the lambda crashes with the following error:
PhoneNumberKit/resource_bundle_accessor.swift:11: Fatal error: could not load resource bundle: from /var/task/PhoneNumberKit_PhoneNumberKit.resources or /workspace/.build/aarch64-unknown-linux-gnu/release/PhoneNumberKit_PhoneNumberKit.resources
Steps to reproduce
- Create a "Hello World" lambda declaring PhoneNumberKit as a dependency
- Add
let phoneNumberKit = PhoneNumberKit() - Execute the lambda and will crash when PhoneNumberKit attempts to load the libphonenumber metadata resource
If possible, minimal yet complete reproducer code (or URL to code)
No response
What version of this project (swift-aws-lambda-runtime) are you using?
main
Swift version
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
Darwin Computer.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
Amazon Linux 2 docker image version
5.9-amazonlinux2
@johnbona Can you review #333 and let us know if this implementation would match your needs. I'm curious to learn about the requirement for the directory name. Can you customize it on PhoneNumberKit side ? Or is it expected to be a specific name ?
Probably fixed by pull request #333 - closing this now. Feel free to reopen if this does not work for your use case