You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error when implementing a middleware with SWIFT_APPROACHABLE_CONCURRENCY #804
Since Xcode 26 beta 5 i cannot comply with the ClientMiddleware protocol of swift-openapi-runtime. The error that I got is Candidate has non-matching type '(HTTPRequest, HTTPBody?, URL, String, nonisolated(nonsending) @Sendable (HTTPRequest, HTTPBody?, URL) async throws -> (HTTPResponse, HTTPBody?)) async throws -> (HTTPResponse, HTTPBody?)' for a structure that seems (and was) to be well "made":
publicstructApiKeyMiddleware:ClientMiddleware{
//The API key to login
privateletapiKey:Stringpublicinit(apiKey:String){self.apiKey=apiKey}publicfuncintercept(_request:HTTPRequest,body:HTTPBody?,baseURL:URL,operationID:String,next: @Sendable(HTTPRequest,HTTPBody?,URL)asyncthrows->(HTTPTypes.HTTPResponse,OpenAPIRuntime.HTTPBody?))asyncthrows->(HTTPTypes.HTTPResponse,OpenAPIRuntime.HTTPBody?){varrequest=requestrequest.headerFields[.init("x-goog-api-key")!]=self.apiKeyreturntryawaitnext(request,body,baseURL)}}
Is this an Xcode/Swift bug or is there something that I'm missing?
running into the exact same problem. There doesn't seem to be a way to prevent Xcode from automatically adding nonisolated(nonsending) to the implementation as far as I can tell.
Ok, seems to be happening only with the SWIFT_APPROACHABLE_CONCURRENCY=YES build setting. While we investigate this, one workaround is to create a dedicated target for your middleware/generated code, and ensure the build setting is turned off in that target only.
Edit: An easier workaround is to add @concurrent to the next parameter, before @Sendable, making it:
changed the title [-]`ClientMiddleware` compliant structure not compliant since Xcode 26 beta 5[/-][+]Error when implementing a middleware with SWIFT_APPROACHABLE_CONCURRENCY[/+]on Aug 8, 2025
Activity
BrentMifsud commentedon Aug 7, 2025
running into the exact same problem. There doesn't seem to be a way to prevent Xcode from automatically adding
nonisolated(nonsending)to the implementation as far as I can tell.czechboy0 commentedon Aug 8, 2025
Ok, seems to be happening only with the SWIFT_APPROACHABLE_CONCURRENCY=YES build setting. While we investigate this, one workaround is to create a dedicated target for your middleware/generated code, and ensure the build setting is turned off in that target only.
Edit: An easier workaround is to add
@concurrentto thenextparameter, before@Sendable, making it:[-]`ClientMiddleware` compliant structure not compliant since Xcode 26 beta 5[/-][+]Error when implementing a middleware with SWIFT_APPROACHABLE_CONCURRENCY[/+]