Skip to content

Commit a8f78da

Browse files
committed
[rc-swift] Start RC Swift implementation (#13931)
1 parent b91dfda commit a8f78da

26 files changed

+693
-762
lines changed

.github/workflows/remoteconfig.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959

6060
strategy:
6161
matrix:
62-
# TODO: macos tests are blocked by https://github.com/erikdoe/ocmock/pull/532
63-
target: [ios, tvos, macos --skip-tests, watchos]
62+
# TODO: add watchos back
63+
target: [ios, tvos, macos --skip-tests]
6464
podspec: [FirebaseRemoteConfig.podspec]
6565
build-env:
6666
- os: macos-14

FirebaseRemoteConfig.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ app update.
4141
'FirebaseCore/Extension/*.h',
4242
'FirebaseInstallations/Source/Library/Private/*.h',
4343
'FirebaseRemoteConfig/Swift/**/*.swift',
44+
'FirebaseRemoteConfig/SwiftNew/**/*.swift',
4445
]
4546
s.public_header_files = base_dir + 'Public/FirebaseRemoteConfig/*.h'
4647
s.resource_bundles = {

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
#import "FirebaseRemoteConfig/Sources/RCNConfigExperiment.h"
2929
#import "FirebaseRemoteConfig/Sources/RCNConfigRealtime.h"
3030
#import "FirebaseRemoteConfig/Sources/RCNConfigValue_Internal.h"
31-
#import "FirebaseRemoteConfig/Sources/RCNDevice.h"
3231
#import "FirebaseRemoteConfig/Sources/RCNPersonalization.h"
3332

33+
#import "FirebaseRemoteConfig/FirebaseRemoteConfig-Swift.h"
34+
3435
/// Remote Config Error Domain.
3536
/// TODO: Rename according to obj-c style for constants.
3637
NSString *const FIRRemoteConfigErrorDomain = @"com.google.remoteconfig.ErrorDomain";

FirebaseRemoteConfig/Sources/FIRRemoteConfigUpdate.m

Lines changed: 0 additions & 33 deletions
This file was deleted.

FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ NS_ASSUME_NONNULL_BEGIN
2929

3030
@class RCNConfigSettings;
3131

32-
@interface FIRRemoteConfigUpdate ()
33-
34-
/// Designated initializer.
35-
- (instancetype)initWithUpdatedKeys:(NSSet<NSString *> *)updatedKeys;
36-
@end
37-
3832
@interface FIRRemoteConfig () {
3933
NSString *_FIRNamespace;
4034
}

FirebaseRemoteConfig/Sources/Private/RCNConfigSettings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
/// for the Realtime service.
104104
@property(nonatomic, readonly, assign) NSTimeInterval realtimeExponentialBackoffThrottleEndTime;
105105
/// Realtime connection attempts.
106-
@property(nonatomic, readwrite, assign) int realtimeRetryCount;
106+
@property(nonatomic, readwrite, assign) NSInteger realtimeRetryCount;
107107

108108
#pragma mark Throttling Methods
109109

FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#import <Foundation/Foundation.h>
1818

1919
@class FIRApp;
20+
@class FIRRemoteConfigUpdate;
2021

2122
/// The Firebase Remote Config service default namespace, to be used if the API method does not
2223
/// specify a different namespace. Use the default namespace if configuring from the Google Firebase
@@ -170,19 +171,6 @@ NS_SWIFT_NAME(RemoteConfigSettings)
170171
@property(nonatomic, assign) NSTimeInterval fetchTimeout;
171172
@end
172173

173-
#pragma mark - FIRRemoteConfigUpdate
174-
/// Used by Remote Config real-time config update service, this class represents changes between the
175-
/// newly fetched config and the current one. An instance of this class is passed to
176-
/// `FIRRemoteConfigUpdateCompletion` when a new config version has been automatically fetched.
177-
NS_SWIFT_NAME(RemoteConfigUpdate)
178-
@interface FIRRemoteConfigUpdate : NSObject
179-
180-
/// Parameter keys whose values have been updated from the currently activated values. Includes
181-
/// keys that are added, deleted, and whose value, value source, or metadata has changed.
182-
@property(nonatomic, readonly, nonnull) NSSet<NSString *> *updatedKeys;
183-
184-
@end
185-
186174
#pragma mark - FIRRemoteConfig
187175
/// Firebase Remote Config class. The class method `remoteConfig()` can be used
188176
/// to fetch, activate and read config results and set default config results on the default

FirebaseRemoteConfig/Sources/RCNConfigContent.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#import "FirebaseRemoteConfig/Sources/RCNConfigContent.h"
1818

19+
#import "FirebaseRemoteConfig/FirebaseRemoteConfig-Swift.h"
20+
1921
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
2022
#import "FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h"
2123
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"

FirebaseRemoteConfig/Sources/RCNConfigFetch.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
2525
#import "FirebaseRemoteConfig/Sources/RCNConfigContent.h"
2626
#import "FirebaseRemoteConfig/Sources/RCNConfigExperiment.h"
27-
#import "FirebaseRemoteConfig/Sources/RCNDevice.h"
27+
28+
#import "FirebaseRemoteConfig/FirebaseRemoteConfig-Swift.h"
29+
2830
@import FirebaseRemoteConfigInterop;
2931

3032
#ifdef RCN_STAGING_SERVER
@@ -134,8 +136,8 @@ - (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration
134136
completionHandler:
135137
(_Nullable FIRRemoteConfigFetchCompletion)completionHandler {
136138
// Note: We expect the googleAppID to always be available.
137-
BOOL hasDeviceContextChanged =
138-
FIRRemoteConfigHasDeviceContextChanged(_settings.deviceContext, _options.googleAppID);
139+
BOOL hasDeviceContextChanged = [Device remoteConfigHasDeviceContextChanged:_settings.deviceContext
140+
projectIdentifier:_options.googleAppID];
139141

140142
__weak RCNConfigFetch *weakSelf = self;
141143
dispatch_async(_lockQueue, ^{
@@ -201,8 +203,8 @@ - (void)fetchConfigWithExpirationDuration:(NSTimeInterval)expirationDuration
201203
- (void)realtimeFetchConfigWithNoExpirationDuration:(NSInteger)fetchAttemptNumber
202204
completionHandler:(RCNConfigFetchCompletion)completionHandler {
203205
// Note: We expect the googleAppID to always be available.
204-
BOOL hasDeviceContextChanged =
205-
FIRRemoteConfigHasDeviceContextChanged(_settings.deviceContext, _options.googleAppID);
206+
BOOL hasDeviceContextChanged = [Device remoteConfigHasDeviceContextChanged:_settings.deviceContext
207+
projectIdentifier:_options.googleAppID];
206208

207209
__weak RCNConfigFetch *weakSelf = self;
208210
dispatch_async(_lockQueue, ^{

FirebaseRemoteConfig/Sources/RCNConfigRealtime.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
#import <GoogleUtilities/GULNSData+zlib.h>
2020
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
2121
#import "FirebaseInstallations/Source/Library/Private/FirebaseInstallationsInternal.h"
22+
#import "FirebaseRemoteConfig/FirebaseRemoteConfig-Swift.h"
2223
#import "FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h"
2324
#import "FirebaseRemoteConfig/Sources/Private/RCNConfigSettings.h"
2425
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
25-
#import "FirebaseRemoteConfig/Sources/RCNDevice.h"
2626

2727
/// URL params
2828
static NSString *const kServerURLDomain = @"https://firebaseremoteconfigrealtime.googleapis.com";
@@ -167,7 +167,7 @@ - (void)propagateErrors:(NSError *)error {
167167
// TESTING ONLY
168168
- (void)triggerListenerForTesting:(void (^_Nonnull)(FIRRemoteConfigUpdate *configUpdate,
169169
NSError *_Nullable error))listener {
170-
listener([[FIRRemoteConfigUpdate alloc] init], nil);
170+
listener([[FIRRemoteConfigUpdate alloc] initWithUpdatedKeys:[[NSSet alloc] init]], nil);
171171
}
172172

173173
#pragma mark - Http Helpers
@@ -328,7 +328,7 @@ - (void)createRequestBodyWithCompletion:(void (^)(NSData *_Nonnull requestBody))
328328
@"sdkVersion:'%@', appInstanceId:'%@'}",
329329
[strongSelf->_options GCMSenderID], namespace,
330330
strongSelf->_configFetch.templateVersionNumber,
331-
strongSelf->_options.googleAppID, FIRRemoteConfigPodVersion(),
331+
strongSelf->_options.googleAppID, Device.remoteConfigPodVersion,
332332
strongSelf->_settings.configInstallationsIdentifier];
333333
NSData *postData = [postBody dataUsingEncoding:NSUTF8StringEncoding];
334334
NSError *compressionError;

0 commit comments

Comments
 (0)