Skip to content

Commit 87e4f44

Browse files
committed
simplify dependencies management
1 parent 9d1a2d7 commit 87e4f44

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

Examples/SAM/Package.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ let package = Package(
5454
dependencies: [
5555
"HttpApiLambda", "SQSLambda",
5656
.product(name: "AWSLambdaTesting", package: "swift-aws-lambda-runtime"),
57-
58-
// at least one target must have this dependency. It ensures Swift builds the dylib
59-
// The dylib is loaded dynamically by the deploy plugin when compiling Deploy.swift.
60-
// The Lambda functions or the tests do not actually depend on it.
61-
// I choose to add the dependency on a test target, because the archive plugin
62-
// links the executable targets with --static-swift-stdlib which cannot include this dynamic library,
63-
// and causes the build to fail
64-
.product(name: "AWSLambdaDeploymentDescriptor", package: "swift-aws-lambda-runtime")
6557
],
6658
// testing data
6759
resources: [

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let package = Package(
5757
.target(
5858
name: "AWSLambdaDeploymentDescriptor",
5959
dependencies: [
60-
.product(name: "Yams", package: "Yams")
60+
.product(name: "Yams", package: "Yams"),
6161
],
6262
path: "Sources/AWSLambdaDeploymentDescriptor"
6363
),
@@ -69,7 +69,10 @@ let package = Package(
6969
description: "Deploy the Lambda ZIP created by the archive plugin. Generates SAM-compliant deployment files based on deployment struct passed by the developer and invoke the SAM command."
7070
)
7171
// permissions: [.writeToPackageDirectory(reason: "This plugin generates a SAM template to describe your deployment")]
72-
)
72+
),
73+
dependencies: [
74+
.byName(name: "AWSLambdaDeploymentDescriptor")
75+
]
7376
),
7477
.testTarget(name: "AWSLambdaRuntimeCoreTests", dependencies: [
7578
.byName(name: "AWSLambdaRuntimeCore"),

Plugins/AWSLambdaDeployer/README.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,7 @@ DeploymentDescriptor {
9292
}
9393
```
9494

95-
3. I add a dependency in my project's `Package.swift`. On a `testTarget`, I add this dependency:
96-
97-
```swift
98-
// on the testTarget()
99-
dependencies: [
100-
// other dependencies
101-
.product(name: "AWSLambdaDeploymentDescriptor", package: "swift-aws-lambda-runtime")
102-
]
103-
```
104-
105-
I also might add this dependency on one of my Lambda functions `executableTarget`. In this case, I make sure it is added only when building on macOS.
106-
107-
```swift
108-
.product(name: "AWSLambdaDeploymentDescriptor", package: "swift-aws-lambda-runtime", condition: .when(platforms: [.macOS]))
109-
```
110-
111-
4. I invoke the archive plugin and the deploy plugin from the command line.
95+
3. I invoke the archive plugin and the deploy plugin from the command line.
11296

11397
```bash
11498

@@ -123,7 +107,7 @@ swift package --disable-sandbox deploy
123107

124108
Similarly to the archiver plugin, the deployer plugin must escape the sandbox because the SAM CLI makes network calls to AWS API (IAM and CloudFormation) to validate and to deploy the template.
125109

126-
5. (optionally) Swift lambda function developer may also use SAM to test the code locally.
110+
4. (optionally) Swift lambda function developer may also use SAM to test the code locally.
127111

128112
```bash
129113
sam local invoke -t sam.yaml -e Tests/LambdaTests/data/apiv2.json HttpApiLambda

0 commit comments

Comments
 (0)