diff --git a/.github/workflows/database.yml b/.github/workflows/database.yml index fac621f6e79..a3b99595001 100644 --- a/.github/workflows/database.yml +++ b/.github/workflows/database.yml @@ -119,14 +119,18 @@ 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. @@ -134,6 +138,7 @@ jobs: runs-on: macos-12 strategy: matrix: + podspec: [FirebaseDatabase.podspec, FirebaseDatabaseSwift.podspec --allow-warnings] target: [ios, tvos, macos] flags: [ '--skip-tests --use-static-frameworks' @@ -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 }} diff --git a/FirebaseDatabase.podspec b/FirebaseDatabase.podspec index 32b0bc64b99..5e4766a581f 100644 --- a/FirebaseDatabase.podspec +++ b/FirebaseDatabase.podspec @@ -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', ] @@ -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}"' diff --git a/FirebaseDatabase/CHANGELOG.md b/FirebaseDatabase/CHANGELOG.md index d9193b48f21..fc1985ff35f 100644 --- a/FirebaseDatabase/CHANGELOG.md +++ b/FirebaseDatabase/CHANGELOG.md @@ -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). diff --git a/FirebaseDatabaseSwift/Sources/Codable/DataSnapshot+ReadDecodable.swift b/FirebaseDatabase/Swift/Sources/Codable/DataSnapshot+ReadDecodable.swift similarity index 94% rename from FirebaseDatabaseSwift/Sources/Codable/DataSnapshot+ReadDecodable.swift rename to FirebaseDatabase/Swift/Sources/Codable/DataSnapshot+ReadDecodable.swift index 0f92876bcde..a0fddc71e9a 100644 --- a/FirebaseDatabaseSwift/Sources/Codable/DataSnapshot+ReadDecodable.swift +++ b/FirebaseDatabase/Swift/Sources/Codable/DataSnapshot+ReadDecodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseDatabase +#if SWIFT_PACKAGE + @_exported import FirebaseDatabaseInternal +#endif // SWIFT_PACKAGE import FirebaseSharedSwift public extension DataSnapshot { diff --git a/FirebaseDatabaseSwift/Sources/Codable/DatabaseReference+WriteEncodable.swift b/FirebaseDatabase/Swift/Sources/Codable/DatabaseReference+WriteEncodable.swift similarity index 95% rename from FirebaseDatabaseSwift/Sources/Codable/DatabaseReference+WriteEncodable.swift rename to FirebaseDatabase/Swift/Sources/Codable/DatabaseReference+WriteEncodable.swift index fdb64296d77..529fc2e6015 100644 --- a/FirebaseDatabaseSwift/Sources/Codable/DatabaseReference+WriteEncodable.swift +++ b/FirebaseDatabase/Swift/Sources/Codable/DatabaseReference+WriteEncodable.swift @@ -15,7 +15,9 @@ */ import Foundation -import FirebaseDatabase +#if SWIFT_PACKAGE + @_exported import FirebaseDatabaseInternal +#endif // SWIFT_PACKAGE import FirebaseSharedSwift public extension DatabaseReference { diff --git a/FirebaseDatabaseSwift/Sources/Codable/EncoderDecoder.swift b/FirebaseDatabase/Swift/Sources/Codable/EncoderDecoder.swift similarity index 89% rename from FirebaseDatabaseSwift/Sources/Codable/EncoderDecoder.swift rename to FirebaseDatabase/Swift/Sources/Codable/EncoderDecoder.swift index 4d847cb6909..ffa58858242 100644 --- a/FirebaseDatabaseSwift/Sources/Codable/EncoderDecoder.swift +++ b/FirebaseDatabase/Swift/Sources/Codable/EncoderDecoder.swift @@ -14,7 +14,9 @@ * limitations under the License. */ -import FirebaseDatabase +#if SWIFT_PACKAGE + @_exported import FirebaseDatabaseInternal +#endif // SWIFT_PACKAGE import FirebaseSharedSwift public extension Database { diff --git a/FirebaseDatabaseSwift/Sources/Codable/ServerTimestamp.swift b/FirebaseDatabase/Swift/Sources/Codable/ServerTimestamp.swift similarity index 95% rename from FirebaseDatabaseSwift/Sources/Codable/ServerTimestamp.swift rename to FirebaseDatabase/Swift/Sources/Codable/ServerTimestamp.swift index 45a0c8349db..ecfd148879c 100644 --- a/FirebaseDatabaseSwift/Sources/Codable/ServerTimestamp.swift +++ b/FirebaseDatabase/Swift/Sources/Codable/ServerTimestamp.swift @@ -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` field to be /// populated with a server timestamp. If a `Codable` object being written diff --git a/FirebaseDatabase/Swift/Sources/SPMSwiftHeaderWorkaround.swift b/FirebaseDatabase/Swift/Sources/SPMSwiftHeaderWorkaround.swift new file mode 100644 index 00000000000..4397eea906e --- /dev/null +++ b/FirebaseDatabase/Swift/Sources/SPMSwiftHeaderWorkaround.swift @@ -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 diff --git a/FirebaseDatabaseSwift.podspec b/FirebaseDatabaseSwift.podspec index 7eb59734905..4d29aa2b95b 100644 --- a/FirebaseDatabaseSwift.podspec +++ b/FirebaseDatabaseSwift.podspec @@ -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 diff --git a/FirebaseDatabaseSwift/CHANGELOG.md b/FirebaseDatabaseSwift/CHANGELOG.md index b6765314266..f3fde9ccaaf 100644 --- a/FirebaseDatabaseSwift/CHANGELOG.md +++ b/FirebaseDatabaseSwift/CHANGELOG.md @@ -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. diff --git a/FirebaseDatabaseSwift/Sources/FirebaseDatabaseSwift.swift b/FirebaseDatabaseSwift/Sources/FirebaseDatabaseSwift.swift new file mode 100644 index 00000000000..d1a4125dddd --- /dev/null +++ b/FirebaseDatabaseSwift/Sources/FirebaseDatabaseSwift.swift @@ -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 diff --git a/Package.swift b/Package.swift index 2e3ff8df4ba..6616a465606 100644 --- a/Package.swift +++ b/Package.swift @@ -556,7 +556,7 @@ let package = Package( ] ), .target( - name: "FirebaseDatabase", + name: "FirebaseDatabaseInternal", dependencies: [ "FirebaseAppCheckInterop", "FirebaseCore", @@ -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( diff --git a/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift b/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift index 3f3ffeb0cad..48eeb534434 100755 --- a/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift +++ b/ReleaseTooling/Sources/FirebaseManifest/FirebaseManifest.swift @@ -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),