Skip to content

Commit d14db42

Browse files
authored
Fix Xcode 15 runtime warning (#11825)
1 parent a69962d commit d14db42

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

FirebasePerformance/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 10.16.0
2+
- [fixed] Fix Xcode 15 runtime warning (#11821).
3+
14
# 10.12.0
25
- [fixed] Make Firebase performance compatible with Xcode15.
36
- [changed] Removed the capability to access Carrier information of the device since that API is deprecated by Apple.

FirebasePerformance/Sources/Instrumentation/Network/FPRNSURLSessionInstrument.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,14 @@ void InstrumentUploadTaskWithRequestFromData(FPRNSURLSessionInstrument *instrume
405405
ThrowExceptionBecauseInstrumentHasBeenDeallocated(selector, instrumentor.instrumentedClass);
406406
}
407407
typedef NSURLSessionUploadTask *(*OriginalImp)(id, SEL, NSURLRequest *, NSData *);
408+
// To avoid a runtime warning in Xcode 15, the given `URLRequest`
409+
// should have a nil `HTTPBody`. To workaround this, the `HTTPBody` data is removed
410+
// and requestData is replaced with it, if it bodyData was `nil`.
411+
NSMutableURLRequest *requestWithoutHTTPBody = [request mutableCopy];
412+
NSData *requestData = bodyData ?: requestWithoutHTTPBody.HTTPBody;
413+
requestWithoutHTTPBody.HTTPBody = nil;
408414
NSURLSessionUploadTask *uploadTask =
409-
((OriginalImp)currentIMP)(session, selector, request, bodyData);
415+
((OriginalImp)currentIMP)(session, selector, requestWithoutHTTPBody, requestData);
410416
if (uploadTask.originalRequest) {
411417
FPRNetworkTrace *trace =
412418
[[FPRNetworkTrace alloc] initWithURLRequest:uploadTask.originalRequest];

0 commit comments

Comments
 (0)