Skip to content

[v11] Replace GULUserDefaults usage with NSUserDefaults #13077

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 2 commits 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
1 change: 0 additions & 1 deletion FirebaseAppCheck.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Pod::Spec.new do |s|
s.dependency 'FirebaseCore', '~> 11.0'
s.dependency 'PromisesObjC', '~> 2.1'
s.dependency 'GoogleUtilities/Environment', '~> 8.0'
s.dependency 'GoogleUtilities/UserDefaults', '~> 8.0'

s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
Expand Down
3 changes: 1 addition & 2 deletions FirebaseAppCheck/Sources/Core/FIRAppCheck.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#import <AppCheckCore/AppCheckCore.h>
#import <FirebaseAppCheckInterop/FirebaseAppCheckInterop.h>
#import <GoogleUtilities/GULUserDefaults.h>

#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckErrors.h"
#import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckProvider.h"
Expand Down Expand Up @@ -93,7 +92,7 @@ - (nullable instancetype)initWithApp:(FIRApp *)app {
[[FIRInternalAppCheckProvider alloc] initWithAppCheckProvider:appCheckProvider];
FIRAppCheckSettings *settings =
[[FIRAppCheckSettings alloc] initWithApp:app
userDefault:[GULUserDefaults standardUserDefaults]
userDefault:[NSUserDefaults standardUserDefaults]
mainBundle:[NSBundle mainBundle]];

GACAppCheck *appCheckCore = [[GACAppCheck alloc] initWithServiceName:serviceName
Expand Down
4 changes: 2 additions & 2 deletions FirebaseAppCheck/Sources/Core/FIRAppCheckSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#import <AppCheckCore/AppCheckCore.h>

@class FIRApp;
@class GULUserDefaults;
@class NSUserDefaults;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -33,7 +33,7 @@ FOUNDATION_EXPORT NSString *const kFIRAppCheckTokenAutoRefreshEnabledInfoPlistKe
@property(nonatomic, assign) BOOL isTokenAutoRefreshEnabled;

- (instancetype)initWithApp:(FIRApp *)firebaseApp
userDefault:(GULUserDefaults *)userDefaults
userDefault:(NSUserDefaults *)userDefaults
mainBundle:(NSBundle *)mainBundle NS_DESIGNATED_INITIALIZER;

- (instancetype)init NS_UNAVAILABLE;
Expand Down
7 changes: 2 additions & 5 deletions FirebaseAppCheck/Sources/Core/FIRAppCheckSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/

#import "FirebaseAppCheck/Sources/Core/FIRAppCheckSettings.h"

#import <GoogleUtilities/GULUserDefaults.h>

#import "FirebaseCore/Extension/FirebaseCoreInternal.h"

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -30,7 +27,7 @@
@interface FIRAppCheckSettings ()

@property(nonatomic, weak, readonly) FIRApp *firebaseApp;
@property(nonatomic, readonly) GULUserDefaults *userDefaults;
@property(nonatomic, readonly) NSUserDefaults *userDefaults;
@property(nonatomic, readonly) NSBundle *mainBundle;
@property(nonatomic, readonly) NSString *userDefaultKey;
@property(nonatomic, assign) BOOL isTokenAutoRefreshConfigured;
Expand All @@ -40,7 +37,7 @@ @interface FIRAppCheckSettings ()
@implementation FIRAppCheckSettings

- (instancetype)initWithApp:(FIRApp *)firebaseApp
userDefault:(GULUserDefaults *)userDefaults
userDefault:(NSUserDefaults *)userDefaults
mainBundle:(NSBundle *)mainBundle {
self = [super init];
if (self) {
Expand Down
3 changes: 1 addition & 2 deletions FirebaseAppCheck/Tests/Unit/Core/FIRAppCheckSettingsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#import <XCTest/XCTest.h>

#import <GoogleUtilities/GULUserDefaults.h>
#import <OCMock/OCMock.h>

#import "FirebaseAppCheck/Sources/Core/FIRAppCheckSettings.h"
Expand Down Expand Up @@ -47,7 +46,7 @@ - (void)setUp {

self.mockApp = OCMClassMock([FIRApp class]);
OCMStub([self.mockApp name]).andReturn(self.appName);
self.mockUserDefaults = OCMClassMock([GULUserDefaults class]);
self.mockUserDefaults = OCMClassMock([NSUserDefaults class]);
self.bundleMock = OCMClassMock([NSBundle class]);

self.settings = [[FIRAppCheckSettings alloc] initWithApp:self.mockApp
Expand Down
1 change: 0 additions & 1 deletion FirebaseAppDistribution.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ iOS SDK for App Distribution for Firebase.

s.dependency 'FirebaseCore', '~> 11.0'
s.dependency 'GoogleUtilities/AppDelegateSwizzler', '~> 8.0'
s.dependency 'GoogleUtilities/UserDefaults', '~> 8.0'
s.dependency 'FirebaseInstallations', '~> 11.0'

s.pod_target_xcconfig = {
Expand Down
7 changes: 3 additions & 4 deletions FirebaseAppDistribution/Sources/FIRAppDistribution.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#import <Foundation/Foundation.h>

#import <GoogleUtilities/GULAppDelegateSwizzler.h>
#import <GoogleUtilities/GULUserDefaults.h>
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
#import "FirebaseInstallations/Source/Library/Private/FirebaseInstallationsInternal.h"

Expand Down Expand Up @@ -60,7 +59,7 @@ @implementation FIRAppDistribution
@synthesize isTesterSignedIn = _isTesterSignedIn;

- (BOOL)isTesterSignedIn {
BOOL signInState = [[GULUserDefaults standardUserDefaults] boolForKey:kFIRFADSignInStateKey];
BOOL signInState = [[NSUserDefaults standardUserDefaults] boolForKey:kFIRFADSignInStateKey];
FIRFADInfoLog(@"Tester is %@signed in.", signInState ? @"" : @"not ");
return signInState;
}
Expand Down Expand Up @@ -176,7 +175,7 @@ - (void)persistTesterSignInStateAndHandleCompletion:(void (^)(NSError *_Nullable
return;
}

[[GULUserDefaults standardUserDefaults] setBool:YES forKey:kFIRFADSignInStateKey];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kFIRFADSignInStateKey];
completion(nil);
}];
}
Expand Down Expand Up @@ -207,7 +206,7 @@ - (NSString *)getAppBuild {

- (void)signOutTester {
FIRFADDebugLog(@"Tester is signed out.");
[[GULUserDefaults standardUserDefaults] setBool:NO forKey:kFIRFADSignInStateKey];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:kFIRFADSignInStateKey];
}

- (NSError *)NSErrorForErrorCodeAndMessage:(FIRAppDistributionError)errorCode
Expand Down
7 changes: 3 additions & 4 deletions FirebaseAppDistribution/Tests/Unit/FIRAppDistributionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#import <XCTest/XCTest.h>

#import <GoogleUtilities/GULAppDelegateSwizzler.h>
#import <GoogleUtilities/GULUserDefaults.h>
#import "FirebaseAppDistribution/Sources/FIRAppDistributionMachO.h"
#import "FirebaseAppDistribution/Sources/FIRAppDistributionUIService.h"
#import "FirebaseAppDistribution/Sources/FIRFADApiService.h"
Expand Down Expand Up @@ -112,7 +111,7 @@ - (void)setUp {

- (void)tearDown {
[super tearDown];
[[GULUserDefaults standardUserDefaults] removeObjectForKey:@"FIRFADSignInState"];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"FIRFADSignInState"];
[_mockFIRAppClass stopMocking];
[_mockFIRFADApiService stopMocking];
[_mockFIRAppDistributionUIService stopMocking];
Expand Down Expand Up @@ -368,7 +367,7 @@ - (void)testFetchNewLatestReleaseUnauthenticatedFailure {
userInfo:@{NSLocalizedDescriptionKey : @"This is unfortunate."}];
[self mockFetchReleasesCompletion:nil error:mockError];
OCMStub([_mockMachO codeHash]).andReturn(@"this-is-old");
[[GULUserDefaults standardUserDefaults] setBool:YES forKey:@"FIRFADSignInState"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FIRFADSignInState"];
XCTAssertTrue([[self appDistribution] isTesterSignedIn]);

XCTestExpectation *expectation = [self expectationWithDescription:@"Fetch latest release fails."];
Expand All @@ -395,7 +394,7 @@ - (void)testFetchNewLatestReleaseUnauthorizedFailure {
userInfo:@{NSLocalizedDescriptionKey : @"This is unfortunate."}];
[self mockFetchReleasesCompletion:nil error:mockError];
OCMStub([_mockMachO codeHash]).andReturn(@"this-is-old");
[[GULUserDefaults standardUserDefaults] setBool:YES forKey:@"FIRFADSignInState"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FIRFADSignInState"];
XCTAssertTrue([[self appDistribution] isTesterSignedIn]);

XCTestExpectation *expectation = [self expectationWithDescription:@"Fetch latest release fails."];
Expand Down
1 change: 0 additions & 1 deletion FirebaseDatabase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
s.dependency 'FirebaseCore', '~> 11.0'
s.dependency 'FirebaseAppCheckInterop', '~> 11.0'
s.dependency 'FirebaseSharedSwift', '~> 11.0'
s.dependency 'GoogleUtilities/UserDefaults', '~> 8.0'
s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
Expand Down
10 changes: 4 additions & 6 deletions FirebaseDatabase/Sources/Core/FRepoInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
* limitations under the License.
*/

#import <GoogleUtilities/GULUserDefaults.h>

#import "FirebaseDatabase/Sources/Constants/FConstants.h"
#import "FirebaseDatabase/Sources/Core/FRepoInfo.h"
#import "FirebaseDatabase/Sources/Constants/FConstants.h"

@interface FRepoInfo ()

Expand Down Expand Up @@ -54,7 +52,7 @@ - (instancetype)initWithHost:(NSString *)aHost
// Get cached internal host if it exists
NSString *internalHostKey =
[NSString stringWithFormat:@"firebase:host:%@", _host];
NSString *cachedInternalHost = [[GULUserDefaults standardUserDefaults]
NSString *cachedInternalHost = [[NSUserDefaults standardUserDefaults]
stringForKey:internalHostKey];
if (cachedInternalHost != nil) {
internalHost = cachedInternalHost;
Expand Down Expand Up @@ -83,7 +81,7 @@ - (void)setInternalHost:(NSString *)newHost {
// Cache the internal host so we don't need to redirect later on
NSString *internalHostKey =
[NSString stringWithFormat:@"firebase:host:%@", self.host];
GULUserDefaults *cache = [GULUserDefaults standardUserDefaults];
NSUserDefaults *cache = [NSUserDefaults standardUserDefaults];
[cache setObject:internalHost forKey:internalHostKey];
[cache synchronize];
}
Expand All @@ -95,7 +93,7 @@ - (void)clearInternalHostCache {
// Remove the cached entry
NSString *internalHostKey =
[NSString stringWithFormat:@"firebase:host:%@", self.host];
GULUserDefaults *cache = [GULUserDefaults standardUserDefaults];
NSUserDefaults *cache = [NSUserDefaults standardUserDefaults];
[cache removeObjectForKey:internalHostKey];
[cache synchronize];
}
Expand Down
1 change: 0 additions & 1 deletion FirebaseInAppMessaging.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ See more product details at https://firebase.google.com/products/in-app-messagin
s.dependency 'FirebaseInstallations', '~> 11.0'
s.dependency 'FirebaseABTesting', '~> 11.0'
s.dependency 'GoogleUtilities/Environment', '~> 8.0'
s.dependency 'GoogleUtilities/UserDefaults', '~> 8.0'
s.dependency 'nanopb', '>= 2.30908.0', '< 2.30911.0'

s.test_spec 'unit' do |unit_tests|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#import "FirebaseInAppMessaging/Sources/Private/Flows/FIRIAMAnalyticsEventLogger.h"

@class FIRIAMClearcutLogger;
@class GULUserDefaults;
@class NSUserDefaults;
@protocol FIRIAMTimeFetcher;
@protocol FIRAnalyticsInterop;

Expand All @@ -35,12 +35,12 @@ NS_ASSUME_NONNULL_BEGIN
/**
*
* @param userDefaults needed for tracking upload timing info persistently.If nil, using
* GULUserDefaults standardUserDefaults. It's defined as a parameter to help with
* NSUserDefaults standardUserDefaults. It's defined as a parameter to help with
* unit testing mocking
*/
- (instancetype)initWithClearcutLogger:(FIRIAMClearcutLogger *)ctLogger
usingTimeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
usingUserDefaults:(nullable GULUserDefaults *)userDefaults
usingUserDefaults:(nullable NSUserDefaults *)userDefaults
analytics:(nullable id<FIRAnalyticsInterop>)analytics;
@end
NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#import <TargetConditionals.h>
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION

#import <GoogleUtilities/GULUserDefaults.h>

#import "FirebaseInAppMessaging/Sources/Analytics/FIRIAMAnalyticsEventLoggerImpl.h"

#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
Expand All @@ -31,7 +29,7 @@
@interface FIRIAMAnalyticsEventLoggerImpl ()
@property(readonly, nonatomic) FIRIAMClearcutLogger *clearCutLogger;
@property(readonly, nonatomic) id<FIRIAMTimeFetcher> timeFetcher;
@property(nonatomic, readonly) GULUserDefaults *userDefaults;
@property(nonatomic, readonly) NSUserDefaults *userDefaults;
@end

// in these kFAXX constants, FA represents FirebaseAnalytics
Expand Down Expand Up @@ -62,13 +60,13 @@ @implementation FIRIAMAnalyticsEventLoggerImpl {

- (instancetype)initWithClearcutLogger:(FIRIAMClearcutLogger *)ctLogger
usingTimeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
usingUserDefaults:(nullable GULUserDefaults *)userDefaults
usingUserDefaults:(nullable NSUserDefaults *)userDefaults
analytics:(nullable id<FIRAnalyticsInterop>)analytics {
if (self = [super init]) {
_clearCutLogger = ctLogger;
_timeFetcher = timeFetcher;
_analytics = analytics;
_userDefaults = userDefaults ? userDefaults : [GULUserDefaults standardUserDefaults];
_userDefaults = userDefaults ? userDefaults : [NSUserDefaults standardUserDefaults];

if (!_analytics) {
FIRLogWarning(kFIRLoggerInAppMessaging, @"I-IAM280002",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#import <TargetConditionals.h>
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION

#import <GoogleUtilities/GULUserDefaults.h>
#import <UIKit/UIKit.h>
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"

Expand Down Expand Up @@ -67,7 +66,7 @@ @interface FIRIAMClearcutUploader () {
@property(nonatomic, readonly) FIRIAMClearcutLogStorage *logStorage;

@property(nonatomic, readonly) FIRIAMClearcutStrategy *strategy;
@property(nonatomic, readonly) GULUserDefaults *userDefaults;
@property(nonatomic, readonly) NSUserDefaults *userDefaults;
@end

static NSString *FIRIAM_UserDefaultsKeyForNextValidClearcutUploadTimeInMills =
Expand All @@ -90,7 +89,7 @@ - (instancetype)initWithRequestSender:(FIRIAMClearcutHttpRequestSender *)request
timeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
logStorage:(FIRIAMClearcutLogStorage *)logStorage
usingStrategy:(FIRIAMClearcutStrategy *)strategy
usingUserDefaults:(nullable GULUserDefaults *)userDefaults {
usingUserDefaults:(nullable NSUserDefaults *)userDefaults {
if (self = [super init]) {
_nextSendScheduled = NO;
_timeFetcher = timeFetcher;
Expand All @@ -108,7 +107,7 @@ - (instancetype)initWithRequestSender:(FIRIAMClearcutHttpRequestSender *)request
name:UISceneWillEnterForegroundNotification
object:nil];
}
_userDefaults = userDefaults ? userDefaults : [GULUserDefaults standardUserDefaults];
_userDefaults = userDefaults ? userDefaults : [NSUserDefaults standardUserDefaults];
// it would be 0 if it does not exist, which is equvilent to saying that
// you can send now
_nextValidSendTimeInMills = (int64_t)
Expand Down
6 changes: 2 additions & 4 deletions FirebaseInAppMessaging/Sources/Flows/FIRIAMBookKeeper.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#import <TargetConditionals.h>
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_VISION

#import <GoogleUtilities/GULUserDefaults.h>

#import "FirebaseCore/Extension/FirebaseCoreInternal.h"

#import "FirebaseInAppMessaging/Sources/FIRCore+InAppMessaging.h"
Expand Down Expand Up @@ -46,7 +44,7 @@ @interface FIRIAMBookKeeperViaUserDefaults ()
@property(nonatomic) double lastDisplayTime;
@property(nonatomic) double lastFetchTime;
@property(nonatomic) double nextFetchWaitTime;
@property(nonatomic, nonnull) GULUserDefaults *defaults;
@property(nonatomic, nonnull) NSUserDefaults *defaults;
@end

@interface FIRIAMImpressionRecord ()
Expand Down Expand Up @@ -87,7 +85,7 @@ - (NSString *)description {

@implementation FIRIAMBookKeeperViaUserDefaults

- (instancetype)initWithUserDefaults:(GULUserDefaults *)userDefaults {
- (instancetype)initWithUserDefaults:(NSUserDefaults *)userDefaults {
if (self = [super init]) {
_defaults = userDefaults;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@class FIRIAMClearcutLogRecord;
@class FIRIAMClearcutHttpRequestSender;
@class FIRIAMClearcutLogStorage;
@class GULUserDefaults;
@class NSUserDefaults;

@protocol FIRIAMTimeFetcher;

Expand Down Expand Up @@ -59,14 +59,14 @@ NS_ASSUME_NONNULL_BEGIN
/**
*
* @param userDefaults needed for tracking upload timing info persistently.If nil, using
* GULUserDefaults standardUserDefaults. It's defined as a parameter to help with
* NSUserDefaults standardUserDefaults. It's defined as a parameter to help with
* unit testing mocking
*/
- (instancetype)initWithRequestSender:(FIRIAMClearcutHttpRequestSender *)requestSender
timeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
logStorage:(FIRIAMClearcutLogStorage *)retryStorage
usingStrategy:(FIRIAMClearcutStrategy *)strategy
usingUserDefaults:(nullable GULUserDefaults *)userDefaults;
usingUserDefaults:(nullable NSUserDefaults *)userDefaults;
/**
* This should return very quickly without blocking on and actual log uploading to
* clearcut server, which is done asynchronously
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

NS_ASSUME_NONNULL_BEGIN

@class GULUserDefaults;
@class NSUserDefaults;

@interface FIRIAMImpressionRecord : NSObject
@property(nonatomic, readonly, copy) NSString *messageID;
Expand Down Expand Up @@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface FIRIAMBookKeeperViaUserDefaults : NSObject <FIRIAMBookKeeper>

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithUserDefaults:(GULUserDefaults *)userDefaults NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithUserDefaults:(NSUserDefaults *)userDefaults NS_DESIGNATED_INITIALIZER;

// for testing, don't use them for production purpose
- (void)cleanupImpressions;
Expand Down
Loading
Loading