Skip to content

Configure ephemeral URLSession for iOS 18.4 simulator to avoid networ… #14766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions FirebaseRemoteConfig/Sources/RCNConfigFetch.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigContent.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigExperiment.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigURLSession.h"
#import "FirebaseRemoteConfig/Sources/RCNDevice.h"
@import FirebaseRemoteConfigInterop;

Expand Down Expand Up @@ -640,8 +641,7 @@ - (NSString *)constructServerURL {
}

- (NSURLSession *)newFetchSession {
NSURLSessionConfiguration *config =
[[NSURLSessionConfiguration defaultSessionConfiguration] copy];
NSURLSessionConfiguration *config = [RCNConfigURLSession RemoteConfigURLSession];
config.timeoutIntervalForRequest = _settings.fetchTimeout;
config.timeoutIntervalForResource = _settings.fetchTimeout;
NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
Expand Down
29 changes: 29 additions & 0 deletions FirebaseRemoteConfig/Sources/RCNConfigURLSession.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import <Foundation/Foundation.h>

@interface RCNConfigURLSession : NSObject

/// Returns an `NSURLSessionConfiguration` instance suitable for Remote Config requests.
///
/// On iOS 18.4+ and visionOS 2.4+ simulators, this method returns an ephemeral session
/// configuration as a workaround for a network request failure bug. See
/// https://developer.apple.com/forums/thread/777999 for details. For all other environments, the
/// default session configuration is returned.
+ (NSURLSessionConfiguration *)RemoteConfigURLSession;

@end
32 changes: 32 additions & 0 deletions FirebaseRemoteConfig/Sources/RCNConfigURLSession.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import "RCNConfigURLSession.h"

@implementation RCNConfigURLSession

+ (NSURLSessionConfiguration *)RemoteConfigURLSession {
// Check if the current operating system version meets the criteria of the affected simulators.
if (@available(iOS 18.4, tvOS 100.0, watchOS 100.0, visionOS 2.4, *)) {
// If the app is running on one of the affected simulator versions (or later for iOS and
// visionOS), use an ephemeral session configuration. Ephemeral sessions do not persist caches,
// cookies, or credential data to disk, which circumvents the known bug.
return [[NSURLSessionConfiguration ephemeralSessionConfiguration] copy];
}
return [[NSURLSessionConfiguration defaultSessionConfiguration] copy];
}

@end
Loading