Skip to content

Commit 2ee43e0

Browse files
authored
[Database] Consolidate Database and DatabaseSwift (#11807)
1 parent a7e3720 commit 2ee43e0

File tree

13 files changed

+94
-11
lines changed

13 files changed

+94
-11
lines changed

.github/workflows/database.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,26 @@ jobs:
119119

120120
strategy:
121121
matrix:
122+
podspec: [FirebaseDatabase.podspec, FirebaseDatabaseSwift.podspec --allow-warnings]
122123
target: [ios, tvos, macos, watchos]
124+
exclude:
125+
- podspec: FirebaseDatabaseSwift.podspec --allow-warnings
126+
target: watchos
123127
steps:
124128
- uses: actions/checkout@v3
125129
- uses: ruby/setup-ruby@v1
126130
- name: Setup Bundler
127131
run: scripts/setup_bundler.sh
128132
- name: Build and test
129-
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseDatabase.podspec --skip-tests --platforms=${{ matrix.target }}
133+
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }} --skip-tests --platforms=${{ matrix.target }}
130134

131135
database-cron-only:
132136
# Don't run on private repo.
133137
if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
134138
runs-on: macos-12
135139
strategy:
136140
matrix:
141+
podspec: [FirebaseDatabase.podspec, FirebaseDatabaseSwift.podspec --allow-warnings]
137142
target: [ios, tvos, macos]
138143
flags: [
139144
'--skip-tests --use-static-frameworks'
@@ -145,4 +150,4 @@ jobs:
145150
- name: Setup Bundler
146151
run: scripts/setup_bundler.sh
147152
- name: PodLibLint database Cron
148-
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseDatabase.podspec --platforms=${{ matrix.target }} ${{ matrix.flags }}
153+
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }} --platforms=${{ matrix.target }} ${{ matrix.flags }}

FirebaseDatabase.podspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
3737
base_dir + '**/*.[mh]',
3838
base_dir + 'third_party/Wrap-leveldb/APLevelDB.mm',
3939
base_dir + 'third_party/SocketRocket/fbase64.c',
40+
'FirebaseDatabase/Swift/Sources/**/*.swift',
4041
'FirebaseAuth/Interop/*.h',
4142
'FirebaseCore/Extension/*.h',
4243
]
@@ -49,6 +50,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
4950
s.dependency 'leveldb-library', '~> 1.22'
5051
s.dependency 'FirebaseCore', '~> 10.0'
5152
s.dependency 'FirebaseAppCheckInterop', '~> 10.17'
53+
s.dependency 'FirebaseSharedSwift', '~> 10.0'
5254
s.pod_target_xcconfig = {
5355
'GCC_C_LANGUAGE_STANDARD' => 'c99',
5456
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'

FirebaseDatabase/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Unreleased
2+
- [feature] The `FirebaseDatabase` module now contains Firebase Database's
3+
Swift-only APIs that were previously only available via the
4+
`FirebaseDatabaseSwift` extension SDK. See the
5+
`FirebaseDatabaseSwift` release note from this release for more details.
6+
17
# 10.0.0
28
- [deprecated] Deprecated `FirebaseDatabase` on watchOS 9 and above.
39
watchOS users should instead use the Database REST API directly (#19272).

FirebaseDatabaseSwift/Sources/Codable/DataSnapshot+ReadDecodable.swift renamed to FirebaseDatabase/Swift/Sources/Codable/DataSnapshot+ReadDecodable.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 FirebaseDatabase
18+
#if SWIFT_PACKAGE
19+
@_exported import FirebaseDatabaseInternal
20+
#endif // SWIFT_PACKAGE
1921
import FirebaseSharedSwift
2022

2123
public extension DataSnapshot {

FirebaseDatabaseSwift/Sources/Codable/DatabaseReference+WriteEncodable.swift renamed to FirebaseDatabase/Swift/Sources/Codable/DatabaseReference+WriteEncodable.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 FirebaseDatabase
18+
#if SWIFT_PACKAGE
19+
@_exported import FirebaseDatabaseInternal
20+
#endif // SWIFT_PACKAGE
1921
import FirebaseSharedSwift
2022

2123
public extension DatabaseReference {

FirebaseDatabaseSwift/Sources/Codable/EncoderDecoder.swift renamed to FirebaseDatabase/Swift/Sources/Codable/EncoderDecoder.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 FirebaseDatabase
17+
#if SWIFT_PACKAGE
18+
@_exported import FirebaseDatabaseInternal
19+
#endif // SWIFT_PACKAGE
1820
import FirebaseSharedSwift
1921

2022
public extension Database {

FirebaseDatabaseSwift/Sources/Codable/ServerTimestamp.swift renamed to FirebaseDatabase/Swift/Sources/Codable/ServerTimestamp.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 FirebaseDatabase
17+
#if SWIFT_PACKAGE
18+
@_exported import FirebaseDatabaseInternal
19+
#endif // SWIFT_PACKAGE
1820

1921
/// A property wrapper that marks an `Optional<Date>` field to be
2022
/// populated with a server timestamp. If a `Codable` object being written
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
#if SWIFT_PACKAGE
16+
@_exported import FirebaseDatabaseInternal
17+
18+
// This is a trick to force generate a `FirebaseDatabase-Swift.h`
19+
// header that re-exports `FirebaseDatabaseInternal` for Objective-C
20+
// clients. It is important for the below code to reference a Remote
21+
// Config symbol defined in Objective-C as that will import the symbol's
22+
// module (`FirebaseDatabaseInternal`) in the generated header. This
23+
// allows Objective-C clients to import Remote Config's Objective-C API
24+
// using `@import FirebaseDatabase;`. This API is not needed for Swift
25+
// clients and is therefore unavailable in a Swift context.
26+
@available(*, unavailable)
27+
@objc public extension Database {
28+
static var __no_op: () -> Void { {} }
29+
}
30+
#endif // SWIFT_PACKAGE

FirebaseDatabaseSwift.podspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,5 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
2828
'FirebaseDatabaseSwift/Sources/**/*.swift',
2929
]
3030

31-
s.dependency 'FirebaseDatabase', '~> 10.0'
32-
s.dependency 'FirebaseSharedSwift', '~> 10.0'
31+
s.dependency 'FirebaseDatabase', '~> 10.17'
3332
end

FirebaseDatabaseSwift/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Unreleased
2+
- [deprecated] All of the public API from `FirebaseDatabaseSwift` can now
3+
be accessed through the `FirebaseDatabase` module. Therefore,
4+
`FirebaseDatabaseSwift` has been deprecated, and will be removed in a
5+
future release. See https://firebase.google.com/docs/ios/swift-migration for
6+
migration instructions.
7+
18
# 9.0.0
29
- [added] **Breaking change:** `FirebaseDatabaseSwift` has exited beta and is
310
now generally available for use.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
#warning(
16+
"All of the public API from `FirebaseDatabaseSwift` can now be accessed through the `FirebaseDatabase` module. Therefore, the `FirebaseDatabaseSwift` module is deprecated and will be removed in the future. See https://firebase.google.com/docs/ios/swift-migration for migration instructions."
17+
)
18+
19+
// The `@_exported` is needed to prevent breaking clients that are using
20+
// types prefixed with the `FirebaseDatabase` namespace.
21+
@_exported import struct FirebaseDatabase.ServerTimestamp

Package.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ let package = Package(
556556
]
557557
),
558558
.target(
559-
name: "FirebaseDatabase",
559+
name: "FirebaseDatabaseInternal",
560560
dependencies: [
561561
"FirebaseAppCheckInterop",
562562
"FirebaseCore",
@@ -606,9 +606,14 @@ let package = Package(
606606
.headerSearchPath("../.."),
607607
]
608608
),
609+
.target(
610+
name: "FirebaseDatabase",
611+
dependencies: ["FirebaseDatabaseInternal", "FirebaseSharedSwift"],
612+
path: "FirebaseDatabase/Swift/Sources"
613+
),
609614
.target(
610615
name: "FirebaseDatabaseSwift",
611-
dependencies: ["FirebaseDatabase", "FirebaseSharedSwift"],
616+
dependencies: ["FirebaseDatabase"],
612617
path: "FirebaseDatabaseSwift/Sources"
613618
),
614619
.testTarget(

ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public let shared = Manifest(
4545
Pod("FirebaseAuth", zip: true),
4646
Pod("FirebaseCrashlytics", zip: true),
4747
Pod("FirebaseDatabase"),
48-
Pod("FirebaseDatabaseSwift", zip: true),
48+
Pod("FirebaseDatabaseSwift", allowWarnings: true, zip: true),
4949
Pod("FirebaseDynamicLinks", platforms: ["ios"], zip: true),
5050
Pod("FirebaseFirestore", allowWarnings: true),
5151
Pod("FirebaseFirestoreSwift", allowWarnings: true, zip: true),

0 commit comments

Comments
 (0)