Skip to content

Modernize the codebase for Swift 6.4 and beyond, groundwork for v3#690

Open
sebsto wants to merge 25 commits into
mainfrom
feat/v3
Open

Modernize the codebase for Swift 6.4 and beyond, groundwork for v3#690
sebsto wants to merge 25 commits into
mainfrom
feat/v3

Conversation

@sebsto

@sebsto sebsto commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Modernizes the codebase for Swift 6.4 (still builds on 6.2, 6.3, and 6.4) and lays the groundwork for v3.

Swift feature flags

Enables four feature flags in Package.swift:

  • NonisolatedNonsendingByDefault
  • ExistentialAny
  • MemberImportVisibility
  • InternalImportsByDefault

Warnings are treated as errors via treatAllWarnings(as: .error). To make it compile: added any to existential types, marked imports as public import where a dependency's types appear in public API, and added a few missing Foundation imports in tests.

The Soto clients under GeneratedClients/ are generated, so scripts/generate-aws-clients.sh now emits any and public import automatically. Two AWSErrorShape.Type uses can't take any yet (soto-core hasn't adopted it), so they stay as warnings via treatWarning("ExistentialAny", as: .warning).

Task-local logger

The runtime binds the per-invocation Logger (carrying requestID / traceID) as the task-local Logger.current for the duration of the handler. Any code in the call tree can read it and inherit the request metadata, with no need to thread context.logger through every function:

import AWSLambdaRuntime
import Logging

func validate(_ event: Request) {
    Logger.current.debug("Validating request")  // carries this invocation's requestID / traceID
}

let runtime = LambdaRuntime { (event: Request, context: LambdaContext) in
    validate(event)
    context.logger.info("Processing request")   // context.logger and Logger.current are equivalent here
    // ...
}

Runtime entry points now default their logger: parameter to Logger.current. Since the project enables NonisolatedNonsendingByDefault, the binding is active across all supported toolchains (6.2 to 6.4). Task-local values propagate through structured concurrency but are not inherited by Task.detached. See the new logging.md article for details.

Testing

Tested with swift build and swift test. CI covers Swift 6.2, 6.3, and 6.4 on Linux.

@sebsto sebsto added the ⚠️ semver/major Breaks existing public API. label Jul 7, 2026
@sebsto sebsto self-assigned this Jul 7, 2026
@sebsto sebsto modified the milestone: 2.x Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ semver/major Breaks existing public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant