@@ -162,14 +162,8 @@ let package = Package(
162162 url: " https://github.com/firebase/nanopb.git " ,
163163 " 2.30909.0 " ..< " 2.30910.0 "
164164 ) ,
165- . package (
166- url: " https://github.com/google/abseil-cpp-binary.git " ,
167- " 1.2022062300.0 " ..< " 1.2022062400.0 "
168- ) ,
169- . package (
170- url: " https://github.com/google/grpc-binary.git " ,
171- " 1.50.1 " ..< " 1.51.0 "
172- ) ,
165+ abseilDependency ( ) ,
166+ grpcDependency ( ) ,
173167 . package (
174168 url: " https://github.com/erikdoe/ocmock.git " ,
175169 revision: " c5eeaa6dde7c308a5ce48ae4d4530462dd3a1110 "
@@ -647,38 +641,13 @@ let package = Package(
647641 . linkedFramework( " QuartzCore " ) ,
648642 ]
649643 ) ,
650-
651- . target(
652- name: " FirebaseFirestoreTarget " ,
653- dependencies: [
654- . target(
655- name: " FirebaseFirestore " ,
656- condition: . when( platforms: [ . iOS, . macCatalyst, . tvOS, . macOS] )
657- ) ,
658- . product( name: " abseil " , package : " abseil-cpp-binary " ) ,
659- . product( name: " gRPC-C++ " , package : " grpc-binary " ) ,
660- . product( name: " nanopb " , package : " nanopb " ) ,
661- " FirebaseCore " ,
662- " leveldb " ,
663- ] ,
664- path: " SwiftPM-PlatformExclude/FirebaseFirestoreWrap " ,
665- linkerSettings: [
666- . linkedFramework( " SystemConfiguration " , . when( platforms: [ . iOS, . macOS, . tvOS] ) ) ,
667- . linkedFramework( " UIKit " , . when( platforms: [ . iOS, . tvOS] ) ) ,
668- . linkedLibrary( " c++ " ) ,
669- ]
670- ) ,
671-
672- . binaryTarget(
673- name: " FirebaseFirestore " ,
674- url: " https://dl.google.com/firebase/ios/bin/firestore/10.11.0/FirebaseFirestore.zip " ,
675- checksum: " 47da0c2d102c90d32ffa93cc5884c5a14eea006325944717b5e8d67ec9b440f3 "
676- ) ,
677-
644+ firestoreWrapperTarget ( ) ,
645+ firestoreTarget ( ) ,
678646 . target(
679647 name: " FirebaseFirestoreSwiftTarget " ,
680648 dependencies: [ . target( name: " FirebaseFirestoreSwift " ,
681- condition: . when( platforms: [ . iOS, . macCatalyst, . tvOS, . macOS] ) ) ] ,
649+ condition: . when( platforms: [ . iOS, . macCatalyst, . tvOS, . macOS,
650+ . firebaseVisionOS] ) ) ] ,
682651 path: " SwiftPM-PlatformExclude/FirebaseFirestoreSwiftWrap "
683652 ) ,
684653
@@ -1323,18 +1292,6 @@ let package = Package(
13231292 cxxLanguageStandard: CXXLanguageStandard . gnucxx14
13241293)
13251294
1326- // This is set when running `scripts/check_firestore_symbols.sh`.
1327- if ProcessInfo . processInfo. environment [ " FIREBASECI_USE_LOCAL_FIRESTORE_ZIP " ] != nil {
1328- if let firestoreIndex = package . targets
1329- . firstIndex ( where: { $0. name == " FirebaseFirestore " } ) {
1330- package . targets [ firestoreIndex] = . binaryTarget(
1331- name: " FirebaseFirestore " ,
1332- // The `xcframework` should be moved to the root of the repo.
1333- path: " FirebaseFirestore.xcframework "
1334- )
1335- }
1336- }
1337-
13381295// MARK: - Helper Functions
13391296
13401297func googleAppMeasurementDependency( ) -> Package . Dependency {
@@ -1348,3 +1305,170 @@ func googleAppMeasurementDependency() -> Package.Dependency {
13481305
13491306 return . package ( url: appMeasurementURL, exact: " 10.12.0 " )
13501307}
1308+
1309+ func abseilDependency( ) -> Package . Dependency {
1310+ let packageInfo : ( url: String , range: Range < Version > )
1311+
1312+ // If building Firestore from source, abseil will need to be built as source
1313+ // as the headers in the binary version of abseil are unusable.
1314+ if ProcessInfo . processInfo. environment [ " FIREBASE_SOURCE_FIRESTORE " ] != nil {
1315+ packageInfo = (
1316+ " https://github.com/firebase/abseil-cpp-SwiftPM.git " ,
1317+ " 0.20220623.0 " ..< " 0.20220624.0 "
1318+ )
1319+ } else {
1320+ packageInfo = (
1321+ " https://github.com/google/abseil-cpp-binary.git " ,
1322+ " 1.2022062300.0 " ..< " 1.2022062400.0 "
1323+ )
1324+ }
1325+
1326+ return . package ( url: packageInfo. url, packageInfo. range)
1327+ }
1328+
1329+ func grpcDependency( ) -> Package . Dependency {
1330+ let packageInfo : ( url: String , range: Range < Version > )
1331+
1332+ // If building Firestore from source, abseil will need to be built as source
1333+ // as the headers in the binary version of abseil are unusable.
1334+ if ProcessInfo . processInfo. environment [ " FIREBASE_SOURCE_FIRESTORE " ] != nil {
1335+ packageInfo = ( " https://github.com/grpc/grpc-ios.git " , " 1.50.1 " ..< " 1.51.0 " )
1336+ } else {
1337+ packageInfo = ( " https://github.com/google/grpc-binary.git " , " 1.50.1 " ..< " 1.51.0 " )
1338+ }
1339+
1340+ return . package ( url: packageInfo. url, packageInfo. range)
1341+ }
1342+
1343+ func firestoreWrapperTarget( ) -> Target {
1344+ if ProcessInfo . processInfo. environment [ " FIREBASE_SOURCE_FIRESTORE " ] != nil {
1345+ return . target(
1346+ name: " FirebaseFirestoreTarget " ,
1347+ dependencies: [ . target( name: " FirebaseFirestore " ,
1348+ condition: . when( platforms: [ . iOS, . tvOS, . macOS,
1349+ . firebaseVisionOS] ) ) ] ,
1350+ path: " SwiftPM-PlatformExclude/FirebaseFirestoreWrap "
1351+ )
1352+ }
1353+
1354+ return . target(
1355+ name: " FirebaseFirestoreTarget " ,
1356+ dependencies: [
1357+ . target(
1358+ name: " FirebaseFirestore " ,
1359+ condition: . when( platforms: [ . iOS, . macCatalyst, . tvOS, . macOS] )
1360+ ) ,
1361+ . product( name: " abseil " , package : " abseil-cpp-binary " ) ,
1362+ . product( name: " gRPC-C++ " , package : " grpc-binary " ) ,
1363+ . product( name: " nanopb " , package : " nanopb " ) ,
1364+ " FirebaseCore " ,
1365+ " leveldb " ,
1366+ ] ,
1367+ path: " SwiftPM-PlatformExclude/FirebaseFirestoreWrap " ,
1368+ linkerSettings: [
1369+ . linkedFramework( " SystemConfiguration " , . when( platforms: [ . iOS, . macOS, . tvOS] ) ) ,
1370+ . linkedFramework( " UIKit " , . when( platforms: [ . iOS, . tvOS] ) ) ,
1371+ . linkedLibrary( " c++ " ) ,
1372+ ]
1373+ )
1374+ }
1375+
1376+ func firestoreTarget( ) -> Target {
1377+ if ProcessInfo . processInfo. environment [ " FIREBASE_SOURCE_FIRESTORE " ] != nil {
1378+ return . target(
1379+ name: " FirebaseFirestore " ,
1380+ dependencies: [
1381+ " FirebaseCore " ,
1382+ " leveldb " ,
1383+ . product( name: " nanopb " , package : " nanopb " ) ,
1384+ . product( name: " abseil " , package : " abseil-cpp-SwiftPM " ) ,
1385+ . product( name: " gRPC-cpp " , package : " grpc-ios " ) ,
1386+ ] ,
1387+ path: " Firestore " ,
1388+ exclude: [
1389+ " CHANGELOG.md " ,
1390+ " CMakeLists.txt " ,
1391+ " Example/ " ,
1392+ " LICENSE " ,
1393+ " Protos/CMakeLists.txt " ,
1394+ " Protos/Podfile " ,
1395+ " Protos/README.md " ,
1396+ " Protos/build_protos.py " ,
1397+ " Protos/cpp/ " ,
1398+ " Protos/lib/ " ,
1399+ " Protos/nanopb_cpp_generator.py " ,
1400+ " Protos/protos/ " ,
1401+ " README.md " ,
1402+ " Source/CMakeLists.txt " ,
1403+ " Swift/ " ,
1404+ " core/CMakeLists.txt " ,
1405+ " core/src/util/config_detected.h.in " ,
1406+ " core/test/ " ,
1407+ " fuzzing/ " ,
1408+ " test.sh " ,
1409+ // Swift PM doesn't recognize hpp files, so we're relying on search paths
1410+ // to find third_party/nlohmann_json/json.hpp.
1411+ " third_party/ " ,
1412+
1413+ // Exclude alternate implementations for other platforms
1414+ " core/src/remote/connectivity_monitor_noop.cc " ,
1415+ " core/src/util/filesystem_win.cc " ,
1416+ " core/src/util/log_stdio.cc " ,
1417+ " core/src/util/secure_random_openssl.cc " ,
1418+ ] ,
1419+ sources: [
1420+ " Source/ " ,
1421+ " Protos/nanopb/ " ,
1422+ " core/include/ " ,
1423+ " core/src " ,
1424+ ] ,
1425+ publicHeadersPath: " Source/Public " ,
1426+ cSettings: [
1427+ . headerSearchPath( " ../ " ) ,
1428+ . headerSearchPath( " Source/Public/FirebaseFirestore " ) ,
1429+ . headerSearchPath( " Protos/nanopb " ) ,
1430+ . define( " PB_FIELD_32BIT " , to: " 1 " ) ,
1431+ . define( " PB_NO_PACKED_STRUCTS " , to: " 1 " ) ,
1432+ . define( " PB_ENABLE_MALLOC " , to: " 1 " ) ,
1433+ . define( " FIRFirestore_VERSION " , to: firebaseVersion) ,
1434+ ] ,
1435+ linkerSettings: [
1436+ . linkedFramework(
1437+ " SystemConfiguration " ,
1438+ . when( platforms: [ . iOS, . macOS, . tvOS, . firebaseVisionOS] )
1439+ ) ,
1440+ . linkedFramework( " UIKit " , . when( platforms: [ . iOS, . tvOS, . firebaseVisionOS] ) ) ,
1441+ . linkedLibrary( " c++ " ) ,
1442+ ]
1443+ )
1444+ } else if ProcessInfo . processInfo. environment [ " FIREBASECI_USE_LOCAL_FIRESTORE_ZIP " ] != nil {
1445+ // This is set when running `scripts/check_firestore_symbols.sh`.
1446+ return . binaryTarget(
1447+ name: " FirebaseFirestore " ,
1448+ // The `xcframework` should be moved to the root of the repo.
1449+ path: " FirebaseFirestore.xcframework "
1450+ )
1451+ }
1452+
1453+ return . binaryTarget(
1454+ name: " FirebaseFirestore " ,
1455+ url: " https://dl.google.com/firebase/ios/bin/firestore/10.11.0/FirebaseFirestore.zip " ,
1456+ checksum: " 47da0c2d102c90d32ffa93cc5884c5a14eea006325944717b5e8d67ec9b440f3 "
1457+ )
1458+ }
1459+
1460+ extension Platform {
1461+ // Xcode dependent value for the visionOS platform. Namespaced with
1462+ // "firebase" prefix to prevent any API collisions (such issues should not
1463+ // arise as the manifest APIs should be confined to the `Package.swift`).
1464+ static var firebaseVisionOS : Self {
1465+ #if swift(>=5.9)
1466+ // For Xcode 15, return the available `visionOS` platform.
1467+ return . visionOS
1468+ #else
1469+ // For Xcode 14, return `iOS` as visionOS is unavailable. Since all targets
1470+ // support iOS, this acts as a no-op.
1471+ return . iOS
1472+ #endif // swift(>=5.9)
1473+ }
1474+ }
0 commit comments