Skip to content

Commit

Permalink
[Config] Consolidate Config and ConfigSwift (#11808)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncooke3 authored Oct 13, 2023
1 parent 2ee43e0 commit 85f4f03
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/remoteconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
target: [ios, tvos, macos, watchos]
podspec: [FirebaseRemoteConfig.podspec, FirebaseRemoteConfigSwift.podspec --skip-tests]
podspec: [FirebaseRemoteConfig.podspec, FirebaseRemoteConfigSwift.podspec --allow-warnings --skip-tests]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
Expand Down
2 changes: 2 additions & 0 deletions FirebaseRemoteConfig.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ app update.
'FirebaseABTesting/Sources/Private/*.h',
'FirebaseCore/Extension/*.h',
'FirebaseInstallations/Source/Library/Private/*.h',
'FirebaseRemoteConfig/Swift/**/*.swift',
]
s.public_header_files = base_dir + 'Public/FirebaseRemoteConfig/*.h'
s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
}
s.dependency 'FirebaseABTesting', '~> 10.0'
s.dependency 'FirebaseSharedSwift', '~> 10.0'
s.dependency 'FirebaseCore', '~> 10.0'
s.dependency 'FirebaseInstallations', '~> 10.0'
s.dependency 'GoogleUtilities/Environment', '~> 7.8'
Expand Down
6 changes: 6 additions & 0 deletions FirebaseRemoteConfig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Unreleased
- [feature] The `FirebaseRemoteConfig` module now contains Firebase Remote
Config's Swift-only APIs that were previously only available via the
`FirebaseRemoteConfigSwift` extension SDK. See the
`FirebaseRemoteConfigSwift` release note from this release for more details.

# 10.12.0
- [fixed] Fix issue of real-time listeners not being properly removed. (#11458)
- [fixed] Fix real-time fetches not being able to fetch the latest template due to an in-progress fetch. (#11465)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

import Foundation
import FirebaseRemoteConfig
#if SWIFT_PACKAGE
@_exported import FirebaseRemoteConfigInternal
#endif // SWIFT_PACKAGE
import FirebaseSharedSwift

public enum RemoteConfigValueCodableError: Error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

import Foundation
import FirebaseRemoteConfig
#if SWIFT_PACKAGE
@_exported import FirebaseRemoteConfigInternal
#endif // SWIFT_PACKAGE
import FirebaseSharedSwift

/// Implement the FirebaseRemoteConfigValueDecoding protocol for the shared Firebase decoder to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
* limitations under the License.
*/

import FirebaseRemoteConfig
#if SWIFT_PACKAGE
@_exported import FirebaseRemoteConfigInternal
#endif // SWIFT_PACKAGE

import SwiftUI

/// A property wrapper that listens to a Remote Config value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

import FirebaseRemoteConfig
#if SWIFT_PACKAGE
@_exported import FirebaseRemoteConfigInternal
#endif // SWIFT_PACKAGE
import FirebaseCore
import SwiftUI

Expand Down
30 changes: 30 additions & 0 deletions FirebaseRemoteConfig/Swift/SPMSwiftHeaderWorkaround.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2023 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.

#if SWIFT_PACKAGE
@_exported import FirebaseRemoteConfigInternal

// This is a trick to force generate a `FirebaseRemoteConfig-Swift.h` header
// that re-exports `FirebaseRemoteConfigInternal` for Objective-C clients. It
// is important for the below code to reference a Remote Config symbol defined
// in Objective-C as that will import the symbol's module
// (`FirebaseRemoteConfigInternal`) in the generated header. This allows
// Objective-C clients to import Remote Config's Objective-C API using
// `@import FirebaseRemoteConfig;`. This API is not needed for Swift clients
// and is therefore unavailable in a Swift context.
@available(*, unavailable)
@objc public extension RemoteConfig {
static var __no_op: () -> Void { {} }
}
#endif // SWIFT_PACKAGE
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

import Foundation
import FirebaseRemoteConfig
#if SWIFT_PACKAGE
@_exported import FirebaseRemoteConfigInternal
#endif // SWIFT_PACKAGE

/// Implements subscript overloads to enable Remote Config values to be accessed
/// in a type-safe way directly from the current config.
Expand Down
3 changes: 1 addition & 2 deletions FirebaseRemoteConfigSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ app update.
]

s.dependency 'FirebaseCore', '~> 10.0'
s.dependency 'FirebaseRemoteConfig', '~> 10.0'
s.dependency 'FirebaseSharedSwift', '~> 10.0'
s.dependency 'FirebaseRemoteConfig', '~> 10.17'

# Run Swift API tests on a real backend.
s.test_spec 'swift-api-tests' do |swift_api|
Expand Down
7 changes: 7 additions & 0 deletions FirebaseRemoteConfigSwift/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Unreleased
- [deprecated] All of the public API from `FirebaseRemoteConfigSwift` can now
be accessed through the `FirebaseRemoteConfig` module. Therefore,
`FirebaseRemoteConfigSwift` has been deprecated, and will be removed in a
future release. See https://firebase.google.com/docs/ios/swift-migration for
migration instructions.

# 10.1.0
- [fixed] Fix CocoaPods release did not include the RemoteConfigProperty feature. (#10371)

Expand Down
24 changes: 24 additions & 0 deletions FirebaseRemoteConfigSwift/Sources/FirebaseRemoteConfigSwift.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2023 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.

#warning(
"All of the public API from `FirebaseRemoteConfigSwift` can now be accessed through the `FirebaseRemoteConfig` module. Therefore, the `FirebaseRemoteConfigSwift` module is deprecated and will be removed in the future. See https://firebase.google.com/docs/ios/swift-migration for migration instructions."
)

// The `@_exported` is needed to prevent breaking clients that are using
// types prefixed with the `FirebaseRemoteConfigSwift` module name (e.g.
// `FirebaseRemoteConfigSwift.RemoteConfigValueCodableError`).
@_exported import enum FirebaseRemoteConfig.RemoteConfigValueCodableError
@_exported import enum FirebaseRemoteConfig.RemoteConfigCodableError
@_exported import struct FirebaseRemoteConfig.RemoteConfigProperty
1 change: 0 additions & 1 deletion FirebaseRemoteConfigSwift/Tests/SwiftAPI/Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import FirebaseRemoteConfig
import FirebaseRemoteConfigSwift

import XCTest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import FirebaseCore
import FirebaseRemoteConfig
import FirebaseRemoteConfigSwift

import XCTest

let ConfigKeyForThisTestOnly = "PropertyWrapperDefaultConfigsTestsKey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import FirebaseRemoteConfig
import FirebaseRemoteConfigSwift

import XCTest

#if compiler(>=5.5.2) && canImport(_Concurrency)
Expand Down
1 change: 0 additions & 1 deletion FirebaseRemoteConfigSwift/Tests/SwiftAPI/Value.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

import FirebaseRemoteConfig
import FirebaseRemoteConfigSwift

import XCTest

Expand Down
21 changes: 16 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,10 @@ let package = Package(
dependencies: [
"FirebaseCore",
"FirebaseInstallations",
"FirebaseRemoteConfig",
// Performance depends on the Obj-C target of FirebaseRemoteConfig to
// avoid including Swift code from the `FirebaseRemoteConfig` target
// that is unneeded.
"FirebaseRemoteConfigInternal",
"FirebaseSessions",
.product(name: "GoogleDataTransport", package: "GoogleDataTransport"),
.product(name: "GULEnvironment", package: "GoogleUtilities"),
Expand Down Expand Up @@ -944,7 +947,7 @@ let package = Package(
// MARK: - Firebase Remote Config

.target(
name: "FirebaseRemoteConfig",
name: "FirebaseRemoteConfigInternal",
dependencies: [
"FirebaseCore",
"FirebaseABTesting",
Expand All @@ -959,7 +962,7 @@ let package = Package(
),
.testTarget(
name: "RemoteConfigUnit",
dependencies: ["FirebaseRemoteConfig", .product(name: "OCMock", package: "ocmock")],
dependencies: ["FirebaseRemoteConfigInternal", .product(name: "OCMock", package: "ocmock")],
path: "FirebaseRemoteConfig/Tests/Unit",
exclude: [
// Need to be evaluated/ported to RC V2.
Expand All @@ -978,17 +981,25 @@ let package = Package(
.headerSearchPath("../../.."),
]
),
.target(
name: "FirebaseRemoteConfig",
dependencies: [
"FirebaseRemoteConfigInternal",
"FirebaseSharedSwift",
],
path: "FirebaseRemoteConfig/Swift"
),
.target(
name: "FirebaseRemoteConfigSwift",
dependencies: [
"FirebaseRemoteConfig",
"FirebaseSharedSwift",
],
path: "FirebaseRemoteConfigSwift/Sources"
),
.testTarget(
name: "RemoteConfigFakeConsole",
dependencies: ["FirebaseRemoteConfigSwift",
dependencies: ["FirebaseRemoteConfig",
"FirebaseRemoteConfigSwift",
"RemoteConfigFakeConsoleObjC"],
path: "FirebaseRemoteConfigSwift/Tests",
exclude: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public let shared = Manifest(
Pod("FirebaseABTesting", zip: true),
Pod("FirebaseAppCheck", zip: true),
Pod("FirebaseRemoteConfig"),
Pod("FirebaseRemoteConfigSwift", zip: true),
Pod("FirebaseRemoteConfigSwift", allowWarnings: true, zip: true),
Pod("FirebaseAppDistribution", isBeta: true, platforms: ["ios"], zip: true),
Pod("FirebaseAuth", zip: true),
Pod("FirebaseCrashlytics", zip: true),
Expand Down

0 comments on commit 85f4f03

Please sign in to comment.