Skip to content

Commit

Permalink
Fix Xcode 15 runtime warning (#11825)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Sep 19, 2023
1 parent a69962d commit d14db42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions FirebasePerformance/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 10.16.0
- [fixed] Fix Xcode 15 runtime warning (#11821).

# 10.12.0
- [fixed] Make Firebase performance compatible with Xcode15.
- [changed] Removed the capability to access Carrier information of the device since that API is deprecated by Apple.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,14 @@ void InstrumentUploadTaskWithRequestFromData(FPRNSURLSessionInstrument *instrume
ThrowExceptionBecauseInstrumentHasBeenDeallocated(selector, instrumentor.instrumentedClass);
}
typedef NSURLSessionUploadTask *(*OriginalImp)(id, SEL, NSURLRequest *, NSData *);
// 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;
NSURLSessionUploadTask *uploadTask =
((OriginalImp)currentIMP)(session, selector, request, bodyData);
((OriginalImp)currentIMP)(session, selector, requestWithoutHTTPBody, requestData);
if (uploadTask.originalRequest) {
FPRNetworkTrace *trace =
[[FPRNetworkTrace alloc] initWithURLRequest:uploadTask.originalRequest];
Expand Down

0 comments on commit d14db42

Please sign in to comment.