Skip to content

Commit 1c16807

Browse files
RC Configure ephemeral URLSession for iOS 18.4 simulator (#14768)
1 parent d9fd34b commit 1c16807

File tree

4 files changed

+67
-1
lines changed

4 files changed

+67
-1
lines changed

FirebaseRemoteConfig/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
- [fixed] Fix an issue where network requests would fail in the iOS 18.4
3+
simulator due to a URLSession bug introduced in Xcode 16.3. (#14728)
4+
15
# 11.10.0
26
- [fixed] Fix intermittent `RCNConfigRealtime` crash due to incorrect parsing of fragmented JSON. (#14518)
37

FirebaseRemoteConfig/Sources/RCNConfigFetch.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
2525
#import "FirebaseRemoteConfig/Sources/RCNConfigContent.h"
2626
#import "FirebaseRemoteConfig/Sources/RCNConfigExperiment.h"
27+
#import "FirebaseRemoteConfig/Sources/RCNConfigSessionConfiguration.h"
2728
#import "FirebaseRemoteConfig/Sources/RCNDevice.h"
2829
@import FirebaseRemoteConfigInterop;
2930

@@ -641,7 +642,7 @@ - (NSString *)constructServerURL {
641642

642643
- (NSURLSession *)newFetchSession {
643644
NSURLSessionConfiguration *config =
644-
[[NSURLSessionConfiguration defaultSessionConfiguration] copy];
645+
[RCNConfigSessionConfiguration remoteConfigSessionConfiguration];
645646
config.timeoutIntervalForRequest = _settings.fetchTimeout;
646647
config.timeoutIntervalForResource = _settings.fetchTimeout;
647648
NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface RCNConfigSessionConfiguration : NSObject
20+
21+
/// Returns an `NSURLSessionConfiguration` instance suitable for Remote Config requests.
22+
///
23+
/// On iOS 18.4+ and visionOS 2.4+ simulators, this method returns an ephemeral session
24+
/// configuration as a workaround for a network request failure bug. See
25+
/// https://developer.apple.com/forums/thread/777999 for details. For all other environments, the
26+
/// default session configuration is returned.
27+
+ (NSURLSessionConfiguration *)remoteConfigSessionConfiguration;
28+
29+
@end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "FirebaseRemoteConfig/Sources/RCNConfigSessionConfiguration.h"
18+
19+
@implementation RCNConfigSessionConfiguration
20+
21+
+ (NSURLSessionConfiguration *)remoteConfigSessionConfiguration {
22+
// Check if the current operating system version meets the criteria of the affected simulators.
23+
if (@available(iOS 18.4, tvOS 100.0, watchOS 100.0, visionOS 2.4, *)) {
24+
// If the app is running on one of the affected simulator versions (or later for iOS and
25+
// visionOS), use an ephemeral session configuration. Ephemeral sessions do not persist caches,
26+
// cookies, or credential data to disk, which circumvents the known bug.
27+
return [NSURLSessionConfiguration ephemeralSessionConfiguration];
28+
}
29+
return [NSURLSessionConfiguration defaultSessionConfiguration];
30+
}
31+
32+
@end

0 commit comments

Comments
 (0)