Skip to content

Commit 05b088d

Browse files
authored
[Config] Merge RemoteConfig and its Swift extension in a non-breaking way (#11720)
1 parent f6ba378 commit 05b088d

13 files changed

+71
-17
lines changed

FirebaseRemoteConfig.podspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ app update.
4040
'FirebaseABTesting/Sources/Private/*.h',
4141
'FirebaseCore/Extension/*.h',
4242
'FirebaseInstallations/Source/Library/Private/*.h',
43+
'FirebaseRemoteConfigSwift/Sources/**/*.swift',
4344
]
4445
s.public_header_files = base_dir + 'Public/FirebaseRemoteConfig/*.h'
4546
s.pod_target_xcconfig = {
4647
'GCC_C_LANGUAGE_STANDARD' => 'c99',
4748
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
4849
}
4950
s.dependency 'FirebaseABTesting', '~> 10.0'
51+
s.dependency 'FirebaseSharedSwift', '~> 10.0'
5052
s.dependency 'FirebaseCore', '~> 10.0'
5153
s.dependency 'FirebaseInstallations', '~> 10.0'
5254
s.dependency 'GoogleUtilities/Environment', '~> 7.8'

FirebaseRemoteConfigSwift.podspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ app update.
3535
s.prefix_header_file = false
3636

3737
s.source_files = [
38-
'FirebaseRemoteConfigSwift/Sources/**/*.swift',
38+
'FirebaseRemoteConfigSwift/Exporter/**/*.swift',
3939
]
4040

4141
s.dependency 'FirebaseRemoteConfig', '~> 10.0'
42-
s.dependency 'FirebaseSharedSwift', '~> 10.0'
4342

4443
# Run Swift API tests on a real backend.
4544
s.test_spec 'swift-api-tests' do |swift_api|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// TODO(ncooke3): Add warning that importing this extension is deprecated.
16+
17+
// The `@_exported` is needed to prevent breaking clients that are using
18+
// types prefixed with the `FirebaseRemoteConfigSwift` module name (e.g.
19+
// `FirebaseRemoteConfigSwift.RemoteConfigValueCodableError`).
20+
@_exported import FirebaseRemoteConfig

FirebaseRemoteConfigSwift/Sources/Codable.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,26 @@
1515
*/
1616

1717
import Foundation
18-
import FirebaseRemoteConfig
18+
#if SWIFT_PACKAGE
19+
@_exported import FirebaseRemoteConfigInternal
20+
#endif // SWIFT_PACKAGE
1921
import FirebaseSharedSwift
2022

23+
#if SWIFT_PACKAGE
24+
// This is a trick to force generate a `FirebaseRemoteConfig-Swift.h` header
25+
// that re-exports `FirebaseRemoteConfigInternal` for Objective-C clients. It
26+
// is important for the below code to reference a Remote Config symbol defined
27+
// in Objective-C as that will import the symbol's module
28+
// (`FirebaseRemoteConfigInternal`) in the generated header. This allows
29+
// Objective-C clients to import Remote Config's Objective-C API using
30+
// `@import FirebaseRemoteConfig;`. This API is not needed for Swift clients
31+
// and is therefore hidden for them for the foreseeable future.
32+
@available(iOS 100, *)
33+
@objc public extension RemoteConfig {
34+
var __do_not_call: String { "" }
35+
}
36+
#endif // SWIFT_PACKAGE
37+
2138
public enum RemoteConfigValueCodableError: Error {
2239
case unsupportedType(String)
2340
}

FirebaseRemoteConfigSwift/Sources/FirebaseRemoteConfigValueDecoderHelper.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
import Foundation
18-
import FirebaseRemoteConfig
18+
#if SWIFT_PACKAGE
19+
@_exported import FirebaseRemoteConfigInternal
20+
#endif // SWIFT_PACKAGE
1921
import FirebaseSharedSwift
2022

2123
/// Implement the FirebaseRemoteConfigValueDecoding protocol for the shared Firebase decoder to

FirebaseRemoteConfigSwift/Sources/PropertyWrapper/RemoteConfigProperty.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import FirebaseRemoteConfig
17+
#if SWIFT_PACKAGE
18+
@_exported import FirebaseRemoteConfigInternal
19+
#endif // SWIFT_PACKAGE
20+
1821
import SwiftUI
1922

2023
/// A property wrapper that listens to a Remote Config value.

FirebaseRemoteConfigSwift/Sources/PropertyWrapper/RemoteConfigValueObservable.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
import FirebaseRemoteConfig
17+
#if SWIFT_PACKAGE
18+
@_exported import FirebaseRemoteConfigInternal
19+
#endif // SWIFT_PACKAGE
1820
import FirebaseCore
1921
import SwiftUI
2022

FirebaseRemoteConfigSwift/Sources/Value.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
import Foundation
18-
import FirebaseRemoteConfig
18+
#if SWIFT_PACKAGE
19+
@_exported import FirebaseRemoteConfigInternal
20+
#endif // SWIFT_PACKAGE
1921

2022
/// Implements subscript overloads to enable Remote Config values to be accessed
2123
/// in a type-safe way directly from the current config.

FirebaseRemoteConfigSwift/Tests/SwiftAPI/Codable.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
import FirebaseRemoteConfig
16-
import FirebaseRemoteConfigSwift
1716

1817
import XCTest
1918

FirebaseRemoteConfigSwift/Tests/SwiftAPI/PropertyWrapperDefaultConfigsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import FirebaseCore
1818
import FirebaseRemoteConfig
19-
import FirebaseRemoteConfigSwift
19+
2020
import XCTest
2121

2222
let ConfigKeyForThisTestOnly = "PropertyWrapperDefaultConfigsTestsKey"

0 commit comments

Comments
 (0)