Skip to content

Commit

Permalink
[Database] Consolidate Database and DatabaseSwift (#11807)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncooke3 authored Oct 13, 2023
1 parent a7e3720 commit 2ee43e0
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 11 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,26 @@ jobs:

strategy:
matrix:
podspec: [FirebaseDatabase.podspec, FirebaseDatabaseSwift.podspec --allow-warnings]
target: [ios, tvos, macos, watchos]
exclude:
- podspec: FirebaseDatabaseSwift.podspec --allow-warnings
target: watchos
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: Build and test
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseDatabase.podspec --skip-tests --platforms=${{ matrix.target }}
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }} --skip-tests --platforms=${{ matrix.target }}

database-cron-only:
# Don't run on private repo.
if: github.event_name == 'schedule' && github.repository == 'Firebase/firebase-ios-sdk'
runs-on: macos-12
strategy:
matrix:
podspec: [FirebaseDatabase.podspec, FirebaseDatabaseSwift.podspec --allow-warnings]
target: [ios, tvos, macos]
flags: [
'--skip-tests --use-static-frameworks'
Expand All @@ -145,4 +150,4 @@ jobs:
- name: Setup Bundler
run: scripts/setup_bundler.sh
- name: PodLibLint database Cron
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseDatabase.podspec --platforms=${{ matrix.target }} ${{ matrix.flags }}
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb ${{ matrix.podspec }} --platforms=${{ matrix.target }} ${{ matrix.flags }}
2 changes: 2 additions & 0 deletions FirebaseDatabase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
base_dir + '**/*.[mh]',
base_dir + 'third_party/Wrap-leveldb/APLevelDB.mm',
base_dir + 'third_party/SocketRocket/fbase64.c',
'FirebaseDatabase/Swift/Sources/**/*.swift',
'FirebaseAuth/Interop/*.h',
'FirebaseCore/Extension/*.h',
]
Expand All @@ -49,6 +50,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
s.dependency 'leveldb-library', '~> 1.22'
s.dependency 'FirebaseCore', '~> 10.0'
s.dependency 'FirebaseAppCheckInterop', '~> 10.17'
s.dependency 'FirebaseSharedSwift', '~> 10.0'
s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
Expand Down
6 changes: 6 additions & 0 deletions FirebaseDatabase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Unreleased
- [feature] The `FirebaseDatabase` module now contains Firebase Database's
Swift-only APIs that were previously only available via the
`FirebaseDatabaseSwift` extension SDK. See the
`FirebaseDatabaseSwift` release note from this release for more details.

# 10.0.0
- [deprecated] Deprecated `FirebaseDatabase` on watchOS 9 and above.
watchOS users should instead use the Database REST API directly (#19272).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

import Foundation
import FirebaseDatabase
#if SWIFT_PACKAGE
@_exported import FirebaseDatabaseInternal
#endif // SWIFT_PACKAGE
import FirebaseSharedSwift

public extension DataSnapshot {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

import Foundation
import FirebaseDatabase
#if SWIFT_PACKAGE
@_exported import FirebaseDatabaseInternal
#endif // SWIFT_PACKAGE
import FirebaseSharedSwift

public extension DatabaseReference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

import FirebaseDatabase
#if SWIFT_PACKAGE
@_exported import FirebaseDatabaseInternal
#endif // SWIFT_PACKAGE
import FirebaseSharedSwift

public extension Database {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

import FirebaseDatabase
#if SWIFT_PACKAGE
@_exported import FirebaseDatabaseInternal
#endif // SWIFT_PACKAGE

/// A property wrapper that marks an `Optional<Date>` field to be
/// populated with a server timestamp. If a `Codable` object being written
Expand Down
30 changes: 30 additions & 0 deletions FirebaseDatabase/Swift/Sources/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 FirebaseDatabaseInternal

// This is a trick to force generate a `FirebaseDatabase-Swift.h`
// header that re-exports `FirebaseDatabaseInternal` 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 (`FirebaseDatabaseInternal`) in the generated header. This
// allows Objective-C clients to import Remote Config's Objective-C API
// using `@import FirebaseDatabase;`. This API is not needed for Swift
// clients and is therefore unavailable in a Swift context.
@available(*, unavailable)
@objc public extension Database {
static var __no_op: () -> Void { {} }
}
#endif // SWIFT_PACKAGE
3 changes: 1 addition & 2 deletions FirebaseDatabaseSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
'FirebaseDatabaseSwift/Sources/**/*.swift',
]

s.dependency 'FirebaseDatabase', '~> 10.0'
s.dependency 'FirebaseSharedSwift', '~> 10.0'
s.dependency 'FirebaseDatabase', '~> 10.17'
end
7 changes: 7 additions & 0 deletions FirebaseDatabaseSwift/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Unreleased
- [deprecated] All of the public API from `FirebaseDatabaseSwift` can now
be accessed through the `FirebaseDatabase` module. Therefore,
`FirebaseDatabaseSwift` has been deprecated, and will be removed in a
future release. See https://firebase.google.com/docs/ios/swift-migration for
migration instructions.

# 9.0.0
- [added] **Breaking change:** `FirebaseDatabaseSwift` has exited beta and is
now generally available for use.
Expand Down
21 changes: 21 additions & 0 deletions FirebaseDatabaseSwift/Sources/FirebaseDatabaseSwift.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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 `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."
)

// The `@_exported` is needed to prevent breaking clients that are using
// types prefixed with the `FirebaseDatabase` namespace.
@_exported import struct FirebaseDatabase.ServerTimestamp
9 changes: 7 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ let package = Package(
]
),
.target(
name: "FirebaseDatabase",
name: "FirebaseDatabaseInternal",
dependencies: [
"FirebaseAppCheckInterop",
"FirebaseCore",
Expand Down Expand Up @@ -606,9 +606,14 @@ let package = Package(
.headerSearchPath("../.."),
]
),
.target(
name: "FirebaseDatabase",
dependencies: ["FirebaseDatabaseInternal", "FirebaseSharedSwift"],
path: "FirebaseDatabase/Swift/Sources"
),
.target(
name: "FirebaseDatabaseSwift",
dependencies: ["FirebaseDatabase", "FirebaseSharedSwift"],
dependencies: ["FirebaseDatabase"],
path: "FirebaseDatabaseSwift/Sources"
),
.testTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public let shared = Manifest(
Pod("FirebaseAuth", zip: true),
Pod("FirebaseCrashlytics", zip: true),
Pod("FirebaseDatabase"),
Pod("FirebaseDatabaseSwift", zip: true),
Pod("FirebaseDatabaseSwift", allowWarnings: true, zip: true),
Pod("FirebaseDynamicLinks", platforms: ["ios"], zip: true),
Pod("FirebaseFirestore", allowWarnings: true),
Pod("FirebaseFirestoreSwift", allowWarnings: true, zip: true),
Expand Down

0 comments on commit 2ee43e0

Please sign in to comment.