Swift 5.3 Resources for Lambda (Linux)

I have a package that I'm intending to deploy on an AWS lambda (following this tutorial). The package has 2 targets - the library is one target, and the lambda is another target (the executable). The lambda target basically just has 1 file (main.swift) and imports the library.

When generating the code and running a standard executable (not for a lambda), all of the normal commands pass (build, run, and test). All of my resources are compiled and work correctly.

However, when I build and deploy on the lambda function I created, I get the following error:

Fatal error: could not load resource bundle:
from /var/task/<package>_<target>.resources
or /src/.build/x86_64-unknown-linux-gnu/release/<package>_<target>.resources:
file <target>/resource_bundle_accessor.swift, line 11

I do see that it is similar to this topic, but when running swift test it works just fine.

I can post my Package.swift file, package structure, just not sure what's relevant.

I figured out that it was a problem with the shell script (package.sh). It wasn't copying over the resources into the lambda.zip it was creating

2 Likes

Out of curiosity, how are you using these resources? what kind of resources?

I think I have this same issue. It seems like my resources are included properly, but I keep getting the same error message no matter what I try. What exactly did you change in the package.sh script?