Skip to content

Commit 1d31fd9

Browse files
authored
[rc-swift] Start RC Swift implementation (#13931)
1 parent bb888cd commit 1d31fd9

26 files changed

+762
-832
lines changed

.github/workflows/remoteconfig.yml

Lines changed: 71 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,15 @@ 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
os: [macos-14]
6666
include:
67-
- os: macos-14
68-
xcode: Xcode_15.3
69-
# TODO(#13078): Fix testing infra to enforce warnings again.
70-
tests: --allow-warnings
7167
# Flaky tests on CI
7268
- os: macos-14
7369
xcode: Xcode_16
74-
tests: --skip-tests
70+
tests: --test-specs=unit
7571
runs-on: ${{ matrix.os }}
7672
steps:
7773
- uses: actions/checkout@v4
@@ -85,75 +81,75 @@ jobs:
8581
scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }} --platforms=${{ matrix.target }} \
8682
${{ matrix.tests }}
8783
88-
spm-package-resolved:
89-
env:
90-
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
91-
runs-on: macos-14
92-
outputs:
93-
cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
94-
steps:
95-
- uses: actions/checkout@v4
96-
- name: Generate Swift Package.resolved
97-
id: swift_package_resolve
98-
run: |
99-
swift package resolve
100-
- name: Generate cache key
101-
id: generate_cache_key
102-
run: |
103-
cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}"
104-
echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT"
105-
- uses: actions/cache/save@v4
106-
id: cache
107-
with:
108-
path: .build
109-
key: ${{ steps.generate_cache_key.outputs.cache_key }}
84+
# spm-package-resolved:
85+
# env:
86+
# FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
87+
# runs-on: macos-14
88+
# outputs:
89+
# cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
90+
# steps:
91+
# - uses: actions/checkout@v4
92+
# - name: Generate Swift Package.resolved
93+
# id: swift_package_resolve
94+
# run: |
95+
# swift package resolve
96+
# - name: Generate cache key
97+
# id: generate_cache_key
98+
# run: |
99+
# cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}"
100+
# echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT"
101+
# - uses: actions/cache/save@v4
102+
# id: cache
103+
# with:
104+
# path: .build
105+
# key: ${{ steps.generate_cache_key.outputs.cache_key }}
110106

111-
spm:
112-
# Don't run on private repo unless it is a PR.
113-
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
114-
needs: [spm-package-resolved]
115-
strategy:
116-
matrix:
117-
include:
118-
- os: macos-13
119-
xcode: Xcode_15.2
120-
target: iOS
121-
- os: macos-14
122-
xcode: Xcode_15.4
123-
target: iOS
124-
- os: macos-15
125-
xcode: Xcode_16
126-
target: iOS
127-
- os: macos-15
128-
xcode: Xcode_16
129-
target: tvOS
130-
- os: macos-15
131-
xcode: Xcode_16
132-
target: macOS
133-
- os: macos-15
134-
xcode: Xcode_16
135-
target: watchOS
136-
- os: macos-15
137-
xcode: Xcode_16
138-
target: catalyst
139-
- os: macos-15
140-
xcode: Xcode_16
141-
target: visionOS
142-
runs-on: ${{ matrix.os }}
143-
steps:
144-
- uses: actions/checkout@v4
145-
- uses: actions/cache/restore@v4
146-
with:
147-
path: .build
148-
key: ${{needs.spm-package-resolved.outputs.cache_key}}
149-
- name: Xcode
150-
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
151-
- name: Initialize xcodebuild
152-
run: scripts/setup_spm_tests.sh
153-
- name: Unit Tests
154-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh RemoteConfigUnit ${{ matrix.target }} spm
155-
- name: Fake Console tests
156-
run: scripts/third_party/travis/retry.sh ./scripts/build.sh RemoteConfigFakeConsole ${{ matrix.target }} spm
107+
# spm:
108+
# # Don't run on private repo unless it is a PR.
109+
# if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
110+
# needs: [spm-package-resolved]
111+
# strategy:
112+
# matrix:
113+
# include:
114+
# - os: macos-13
115+
# xcode: Xcode_15.2
116+
# target: iOS
117+
# - os: macos-14
118+
# xcode: Xcode_15.4
119+
# target: iOS
120+
# - os: macos-15
121+
# xcode: Xcode_16
122+
# target: iOS
123+
# - os: macos-15
124+
# xcode: Xcode_16
125+
# target: tvOS
126+
# - os: macos-15
127+
# xcode: Xcode_16
128+
# target: macOS
129+
# - os: macos-15
130+
# xcode: Xcode_16
131+
# target: watchOS
132+
# - os: macos-15
133+
# xcode: Xcode_16
134+
# target: catalyst
135+
# - os: macos-15
136+
# xcode: Xcode_16
137+
# target: visionOS
138+
# runs-on: ${{ matrix.os }}
139+
# steps:
140+
# - uses: actions/checkout@v4
141+
# - uses: actions/cache/restore@v4
142+
# with:
143+
# path: .build
144+
# key: ${{needs.spm-package-resolved.outputs.cache_key}}
145+
# - name: Xcode
146+
# run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
147+
# - name: Initialize xcodebuild
148+
# run: scripts/setup_spm_tests.sh
149+
# - name: Unit Tests
150+
# run: scripts/third_party/travis/retry.sh ./scripts/build.sh RemoteConfigUnit ${{ matrix.target }} spm
151+
# - name: Fake Console tests
152+
# run: scripts/third_party/travis/retry.sh ./scripts/build.sh RemoteConfigFakeConsole ${{ matrix.target }} spm
157153

158154
catalyst:
159155
# Don't run on private repo unless it is a PR.

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
@@ -101,7 +101,7 @@
101101
/// for the Realtime service.
102102
@property(nonatomic, readonly, assign) NSTimeInterval realtimeExponentialBackoffThrottleEndTime;
103103
/// Realtime connection attempts.
104-
@property(nonatomic, readwrite, assign) int realtimeRetryCount;
104+
@property(nonatomic, readwrite, assign) NSInteger realtimeRetryCount;
105105

106106
#pragma mark Throttling Methods
107107

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)