// swift-tools-version:6.1 // This example has to be in Swift 6.1 because it is used in the test archive plugin CI job // That job runs on GitHub's ubuntu-latest environment that only supports Swift 6.1 // https://github.com/actions/runner-images?tab=readme-ov-file // https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md // We can update to Swift 6.2 when GitHUb hosts will have Swift 6.2 import PackageDescription // needed for CI to test the local version of the library import struct Foundation.URL let package = Package( name: "ResourcesPackaging", platforms: [.macOS(.v15)], products: [ .executable(name: "MyLambda", targets: ["MyLambda"]) ], dependencies: [ .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "2.0.0") ], targets: [ .executableTarget( name: "MyLambda", dependencies: [ .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime") ], path: ".", resources: [ .process("hello.txt") ] ) ] ) if let localDepsPath = Context.environment["LAMBDA_USE_LOCAL_DEPS"], localDepsPath != "", let v = try? URL(fileURLWithPath: localDepsPath).resourceValues(forKeys: [.isDirectoryKey]), v.isDirectory == true { // when we use the local runtime as deps, let's remove the dependency added above let indexToRemove = package.dependencies.firstIndex { dependency in if case .sourceControl( name: _, location: "https://github.com/swift-server/swift-aws-lambda-runtime.git", requirement: _ ) = dependency.kind { return true } return false } if let indexToRemove { package.dependencies.remove(at: indexToRemove) } // then we add the dependency on LAMBDA_USE_LOCAL_DEPS' path (typically ../..) print("[INFO] Compiling against swift-aws-lambda-runtime located at \(localDepsPath)") package.dependencies += [ .package(name: "swift-aws-lambda-runtime", path: localDepsPath) ] }