Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
that reduces the number of billed document reads when documents were deleted
on the server while the client was not actively listening to the query
(e.g. while the client was offline). (#11457)
- [added] Developers using Firestore on **visionOS** must use a source
Firestore distribution rather than the default binary distribution. To do
this, quit Xcode and open the desired project from the command line
with the `FIREBASE_SOURCE_FIRESTORE` environment variable:
```
open --env FIREBASE_SOURCE_FIRESTORE /path/to/project.xcodeproj
```
To go back to using the binary distribution of Firestore, quit Xcode and
open Xcode like normal, without the environment variable. (#11492)

# 10.11.0
- [feature] Expose MultiDb API for public preview. (#10465)
Expand Down
222 changes: 173 additions & 49 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,8 @@ let package = Package(
url: "https://github.com/firebase/nanopb.git",
"2.30909.0" ..< "2.30910.0"
),
.package(
url: "https://github.com/google/abseil-cpp-binary.git",
"1.2022062300.0" ..< "1.2022062400.0"
),
.package(
url: "https://github.com/google/grpc-binary.git",
"1.50.1" ..< "1.51.0"
),
abseilDependency(),
grpcDependency(),
.package(
url: "https://github.com/erikdoe/ocmock.git",
revision: "c5eeaa6dde7c308a5ce48ae4d4530462dd3a1110"
Expand Down Expand Up @@ -647,38 +641,13 @@ let package = Package(
.linkedFramework("QuartzCore"),
]
),

.target(
name: "FirebaseFirestoreTarget",
dependencies: [
.target(
name: "FirebaseFirestore",
condition: .when(platforms: [.iOS, .macCatalyst, .tvOS, .macOS])
),
.product(name: "abseil", package: "abseil-cpp-binary"),
.product(name: "gRPC-C++", package: "grpc-binary"),
.product(name: "nanopb", package: "nanopb"),
"FirebaseCore",
"leveldb",
],
path: "SwiftPM-PlatformExclude/FirebaseFirestoreWrap",
linkerSettings: [
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
.linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS])),
.linkedLibrary("c++"),
]
),

.binaryTarget(
name: "FirebaseFirestore",
url: "https://dl.google.com/firebase/ios/bin/firestore/10.11.0/FirebaseFirestore.zip",
checksum: "47da0c2d102c90d32ffa93cc5884c5a14eea006325944717b5e8d67ec9b440f3"
),

firestoreWrapperTarget(),
firestoreTarget(),
.target(
name: "FirebaseFirestoreSwiftTarget",
dependencies: [.target(name: "FirebaseFirestoreSwift",
condition: .when(platforms: [.iOS, .macCatalyst, .tvOS, .macOS]))],
condition: .when(platforms: [.iOS, .macCatalyst, .tvOS, .macOS,
.firebaseVisionOS]))],
path: "SwiftPM-PlatformExclude/FirebaseFirestoreSwiftWrap"
),

Expand Down Expand Up @@ -1323,18 +1292,6 @@ let package = Package(
cxxLanguageStandard: CXXLanguageStandard.gnucxx14
)

// This is set when running `scripts/check_firestore_symbols.sh`.
if ProcessInfo.processInfo.environment["FIREBASECI_USE_LOCAL_FIRESTORE_ZIP"] != nil {
if let firestoreIndex = package.targets
.firstIndex(where: { $0.name == "FirebaseFirestore" }) {
package.targets[firestoreIndex] = .binaryTarget(
name: "FirebaseFirestore",
// The `xcframework` should be moved to the root of the repo.
path: "FirebaseFirestore.xcframework"
)
}
}

// MARK: - Helper Functions

func googleAppMeasurementDependency() -> Package.Dependency {
Expand All @@ -1348,3 +1305,170 @@ func googleAppMeasurementDependency() -> Package.Dependency {

return .package(url: appMeasurementURL, exact: "10.12.0")
}

func abseilDependency() -> Package.Dependency {
let packageInfo: (url: String, range: Range<Version>)

// If building Firestore from source, abseil will need to be built as source
// as the headers in the binary version of abseil are unusable.
if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil {
packageInfo = (
"https://github.com/firebase/abseil-cpp-SwiftPM.git",
"0.20220623.0" ..< "0.20220624.0"
)
} else {
packageInfo = (
"https://github.com/google/abseil-cpp-binary.git",
"1.2022062300.0" ..< "1.2022062400.0"
)
}

return .package(url: packageInfo.url, packageInfo.range)
}

func grpcDependency() -> Package.Dependency {
let packageInfo: (url: String, range: Range<Version>)

// If building Firestore from source, abseil will need to be built as source
// as the headers in the binary version of abseil are unusable.
if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil {
packageInfo = ("https://github.com/grpc/grpc-ios.git", "1.50.1" ..< "1.51.0")
} else {
packageInfo = ("https://github.com/google/grpc-binary.git", "1.50.1" ..< "1.51.0")
}

return .package(url: packageInfo.url, packageInfo.range)
}

func firestoreWrapperTarget() -> Target {
if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil {
return .target(
name: "FirebaseFirestoreTarget",
dependencies: [.target(name: "FirebaseFirestore",
condition: .when(platforms: [.iOS, .tvOS, .macOS,
.firebaseVisionOS]))],
path: "SwiftPM-PlatformExclude/FirebaseFirestoreWrap"
)
}

return .target(
name: "FirebaseFirestoreTarget",
dependencies: [
.target(
name: "FirebaseFirestore",
condition: .when(platforms: [.iOS, .macCatalyst, .tvOS, .macOS])
),
.product(name: "abseil", package: "abseil-cpp-binary"),
.product(name: "gRPC-C++", package: "grpc-binary"),
.product(name: "nanopb", package: "nanopb"),
"FirebaseCore",
"leveldb",
],
path: "SwiftPM-PlatformExclude/FirebaseFirestoreWrap",
linkerSettings: [
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
.linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS])),
.linkedLibrary("c++"),
]
)
}

func firestoreTarget() -> Target {
if ProcessInfo.processInfo.environment["FIREBASE_SOURCE_FIRESTORE"] != nil {
return .target(
name: "FirebaseFirestore",
dependencies: [
"FirebaseCore",
"leveldb",
.product(name: "nanopb", package: "nanopb"),
.product(name: "abseil", package: "abseil-cpp-SwiftPM"),
.product(name: "gRPC-cpp", package: "grpc-ios"),
],
path: "Firestore",
exclude: [
"CHANGELOG.md",
"CMakeLists.txt",
"Example/",
"LICENSE",
"Protos/CMakeLists.txt",
"Protos/Podfile",
"Protos/README.md",
"Protos/build_protos.py",
"Protos/cpp/",
"Protos/lib/",
"Protos/nanopb_cpp_generator.py",
"Protos/protos/",
"README.md",
"Source/CMakeLists.txt",
"Swift/",
"core/CMakeLists.txt",
"core/src/util/config_detected.h.in",
"core/test/",
"fuzzing/",
"test.sh",
// Swift PM doesn't recognize hpp files, so we're relying on search paths
// to find third_party/nlohmann_json/json.hpp.
"third_party/",

// Exclude alternate implementations for other platforms
"core/src/remote/connectivity_monitor_noop.cc",
"core/src/util/filesystem_win.cc",
"core/src/util/log_stdio.cc",
"core/src/util/secure_random_openssl.cc",
],
sources: [
"Source/",
"Protos/nanopb/",
"core/include/",
"core/src",
],
publicHeadersPath: "Source/Public",
cSettings: [
.headerSearchPath("../"),
.headerSearchPath("Source/Public/FirebaseFirestore"),
.headerSearchPath("Protos/nanopb"),
.define("PB_FIELD_32BIT", to: "1"),
.define("PB_NO_PACKED_STRUCTS", to: "1"),
.define("PB_ENABLE_MALLOC", to: "1"),
.define("FIRFirestore_VERSION", to: firebaseVersion),
],
linkerSettings: [
.linkedFramework(
"SystemConfiguration",
.when(platforms: [.iOS, .macOS, .tvOS, .firebaseVisionOS])
),
.linkedFramework("UIKit", .when(platforms: [.iOS, .tvOS, .firebaseVisionOS])),
.linkedLibrary("c++"),
]
)
} else if ProcessInfo.processInfo.environment["FIREBASECI_USE_LOCAL_FIRESTORE_ZIP"] != nil {
// This is set when running `scripts/check_firestore_symbols.sh`.
return .binaryTarget(
name: "FirebaseFirestore",
// The `xcframework` should be moved to the root of the repo.
path: "FirebaseFirestore.xcframework"
)
}

return .binaryTarget(
name: "FirebaseFirestore",
url: "https://dl.google.com/firebase/ios/bin/firestore/10.11.0/FirebaseFirestore.zip",
checksum: "47da0c2d102c90d32ffa93cc5884c5a14eea006325944717b5e8d67ec9b440f3"
)
}

extension Platform {
// Xcode dependent value for the visionOS platform. Namespaced with
// "firebase" prefix to prevent any API collisions (such issues should not
// arise as the manifest APIs should be confined to the `Package.swift`).
static var firebaseVisionOS: Self {
#if swift(>=5.9)
// For Xcode 15, return the available `visionOS` platform.
return .visionOS
#else
// For Xcode 14, return `iOS` as visionOS is unavailable. Since all targets
// support iOS, this acts as a no-op.
return .iOS
#endif // swift(>=5.9)
}
}