diff --git a/FirebasePerformance/Sources/Instrumentation/Network/FPRNSURLSessionInstrument.m b/FirebasePerformance/Sources/Instrumentation/Network/FPRNSURLSessionInstrument.m index 32b2efc2f02..123d3cdb3e9 100644 --- a/FirebasePerformance/Sources/Instrumentation/Network/FPRNSURLSessionInstrument.m +++ b/FirebasePerformance/Sources/Instrumentation/Network/FPRNSURLSessionInstrument.m @@ -453,7 +453,13 @@ void InstrumentUploadTaskWithRequestFromDataCompletionHandler(FPRNSURLSessionIns } typedef NSURLSessionUploadTask *(*OriginalImp)(id, SEL, NSURLRequest *, NSData *, FPRDataTaskCompletionHandler); - return ((OriginalImp)currentIMP)(session, selector, request, bodyData, + // To avoid a runtime warning in Xcode 15, the given `URLRequest` + // should have a nil `HTTPBody`. To workaround this, the `HTTPBody` data is removed + // and requestData is replaced with it, if it bodyData was `nil`. + NSMutableURLRequest *requestWithoutHTTPBody = [request mutableCopy]; + NSData *requestData = bodyData ?: requestWithoutHTTPBody.HTTPBody; + requestWithoutHTTPBody.HTTPBody = nil; + return ((OriginalImp)currentIMP)(session, selector, requestWithoutHTTPBody, requestData, wrappedCompletionHandler); }]; }