diff --git a/.github/workflows/scripts/swift-integration.dart b/.github/workflows/scripts/swift-integration.dart index 8ec3d71b7380..6169df4bb1d4 100644 --- a/.github/workflows/scripts/swift-integration.dart +++ b/.github/workflows/scripts/swift-integration.dart @@ -14,6 +14,8 @@ void main() async { await buildSwiftExampleApp('macos', 'firebase_remote_config'); await buildSwiftExampleApp('ios', 'cloud_functions'); await buildSwiftExampleApp('macos', 'cloud_functions'); + await buildSwiftExampleApp('ios', 'firebase_database'); + await buildSwiftExampleApp('macos', 'firebase_database'); } Future deleteFirstLine(String filePath) async { diff --git a/packages/firebase_database/firebase_database/example/.gitignore b/packages/firebase_database/firebase_database/example/.gitignore index 29a3a5017f04..79c113f9b501 100644 --- a/packages/firebase_database/firebase_database/example/.gitignore +++ b/packages/firebase_database/firebase_database/example/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related diff --git a/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/project.pbxproj b/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/project.pbxproj index 699f971cb9d1..560608d749dc 100644 --- a/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/project.pbxproj @@ -8,14 +8,13 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 28220DBFD8511F8203F69B5D /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E272CCB32B805BD1E8B419D /* Pods_RunnerTests.framework */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - FB9B1AE36B8614676A3FA6B7 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B759EA3B02AE88AECC794C6 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -47,9 +46,6 @@ 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 4B759EA3B02AE88AECC794C6 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 5E272CCB32B805BD1E8B419D /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 6FEEF58C9913C35E77FF7501 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -60,11 +56,6 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - B471B01028E43C4D3FC88438 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; - C87474AC2993C90748DC97EE /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - CA7BEC5DBA01DE75A7764F66 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - E75A29D73D8F0FBB8F1BCEF6 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; - FA592A902E5A8F56EB0F0580 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -72,7 +63,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 28220DBFD8511F8203F69B5D /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -80,7 +70,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - FB9B1AE36B8614676A3FA6B7 /* Pods_Runner.framework in Frameworks */, + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -95,29 +85,6 @@ path = RunnerTests; sourceTree = ""; }; - 575D9720CE0D60A3D7621C90 /* Pods */ = { - isa = PBXGroup; - children = ( - 6FEEF58C9913C35E77FF7501 /* Pods-Runner.debug.xcconfig */, - C87474AC2993C90748DC97EE /* Pods-Runner.release.xcconfig */, - CA7BEC5DBA01DE75A7764F66 /* Pods-Runner.profile.xcconfig */, - FA592A902E5A8F56EB0F0580 /* Pods-RunnerTests.debug.xcconfig */, - B471B01028E43C4D3FC88438 /* Pods-RunnerTests.release.xcconfig */, - E75A29D73D8F0FBB8F1BCEF6 /* Pods-RunnerTests.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; - 7ED75894B38C838548EB0C52 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 4B759EA3B02AE88AECC794C6 /* Pods_Runner.framework */, - 5E272CCB32B805BD1E8B419D /* Pods_RunnerTests.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -136,8 +103,6 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, - 575D9720CE0D60A3D7621C90 /* Pods */, - 7ED75894B38C838548EB0C52 /* Frameworks */, ); sourceTree = ""; }; @@ -172,7 +137,6 @@ isa = PBXNativeTarget; buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - A6B77F0192F6136F59EF9AF0 /* [CP] Check Pods Manifest.lock */, 331C807D294A63A400263BE5 /* Sources */, 331C807F294A63A400263BE5 /* Resources */, 3A1CC5C1C175EAC210B3D882 /* Frameworks */, @@ -191,20 +155,21 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 5CC3C84F88673AFB90740BBB /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 7E3B5081D674CDB84A95EFDA /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = Runner; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); productName = Runner; productReference = 97C146EE1CF9000F007C117D /* Runner.app */; productType = "com.apple.product-type.application"; @@ -238,6 +203,9 @@ Base, ); mainGroup = 97C146E51CF9000F007C117D; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, + ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; projectRoot = ""; @@ -286,45 +254,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 5CC3C84F88673AFB90740BBB /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 7E3B5081D674CDB84A95EFDA /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -340,28 +269,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - A6B77F0192F6136F59EF9AF0 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -474,6 +381,7 @@ DEVELOPMENT_TEAM = 7K2HVKAM5V; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -488,7 +396,6 @@ }; 331C8088294A63A400263BE5 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FA592A902E5A8F56EB0F0580 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -506,7 +413,6 @@ }; 331C8089294A63A400263BE5 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = B471B01028E43C4D3FC88438 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -522,7 +428,6 @@ }; 331C808A294A63A400263BE5 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E75A29D73D8F0FBB8F1BCEF6 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -657,6 +562,7 @@ DEVELOPMENT_TEAM = 7K2HVKAM5V; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -680,6 +586,7 @@ DEVELOPMENT_TEAM = 7K2HVKAM5V; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -726,6 +633,20 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = FlutterGeneratedPluginSwiftPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 8e3ca5dfe193..15c313e206f8 100644 --- a/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/firebase_database/firebase_database/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -5,6 +5,24 @@ + + + + + + + + + + - - com.apple.security.app-sandbox - - com.apple.security.network.client - - + diff --git a/packages/firebase_database/firebase_database/ios/firebase_database.podspec b/packages/firebase_database/firebase_database/ios/firebase_database.podspec index 39c1e74144e5..40e8a95786e1 100755 --- a/packages/firebase_database/firebase_database/ios/firebase_database.podspec +++ b/packages/firebase_database/firebase_database/ios/firebase_database.podspec @@ -25,8 +25,8 @@ Pod::Spec.new do |s| s.authors = 'The Chromium Authors' s.source = { :path => '.' } - s.source_files = 'Classes/**/*.{h,m}' - s.public_header_files = 'Classes/*.h' + s.source_files = 'firebase_database/Sources/firebase_database/**/*.{h,m}' + s.public_header_files = 'firebase_database/Sources/firebase_database/include/*.h' s.ios.deployment_target = '13.0' s.dependency 'Flutter' @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.static_framework = true s.pod_target_xcconfig = { - 'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\@\\\"#{library_version}\\\" LIBRARY_NAME=\\@\\\"flutter-fire-rtdb\\\"", + 'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\\"#{library_version}\\\" LIBRARY_NAME=\\\"flutter-fire-rtdb\\\"", 'DEFINES_MODULE' => 'YES' } end diff --git a/packages/firebase_database/firebase_database/ios/firebase_database/Package.swift b/packages/firebase_database/firebase_database/ios/firebase_database/Package.swift new file mode 100644 index 000000000000..899dfae7e639 --- /dev/null +++ b/packages/firebase_database/firebase_database/ios/firebase_database/Package.swift @@ -0,0 +1,115 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +// Copyright 2024, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import Foundation +import PackageDescription + +enum ConfigurationError: Error { + case fileNotFound(String) + case parsingError(String) + case invalidFormat(String) +} + +let databaseDirectory = String(URL(string: #file)!.deletingLastPathComponent().absoluteString + .dropLast()) + +func loadFirebaseSDKVersion() throws -> String { + let firebaseCoreScriptPath = NSString.path(withComponents: [ + databaseDirectory, + "..", + "generated_firebase_sdk_version.txt", + ]) + do { + let version = try String(contentsOfFile: firebaseCoreScriptPath, encoding: .utf8) + .trimmingCharacters(in: .whitespacesAndNewlines) + return version + } catch { + throw ConfigurationError + .fileNotFound("Error loading or parsing generated_firebase_sdk_version.txt: \(error)") + } +} + +func loadPubspecVersions() throws -> (packageVersion: String, firebaseCoreVersion: String) { + let pubspecPath = NSString.path(withComponents: [databaseDirectory, "..", "..", "pubspec.yaml"]) + do { + let yamlString = try String(contentsOfFile: pubspecPath, encoding: .utf8) + let lines = yamlString.split(separator: "\n") + + guard let packageVersionLine = lines.first(where: { $0.starts(with: "version:") }) else { + throw ConfigurationError.invalidFormat("No package version line found in pubspec.yaml") + } + var packageVersion = packageVersionLine.split(separator: ":")[1] + .trimmingCharacters(in: .whitespaces) + .replacingOccurrences(of: "+", with: "-") + packageVersion = packageVersion.replacingOccurrences(of: "^", with: "") + + guard let firebaseCoreVersionLine = lines.first(where: { $0.contains("firebase_core:") }) else { + throw ConfigurationError + .invalidFormat("No firebase_core dependency version line found in pubspec.yaml") + } + var firebaseCoreVersion = firebaseCoreVersionLine.split(separator: ":")[1] + .trimmingCharacters(in: .whitespaces) + firebaseCoreVersion = firebaseCoreVersion.replacingOccurrences(of: "^", with: "") + + return (packageVersion, firebaseCoreVersion) + } catch { + throw ConfigurationError.fileNotFound("Error loading or parsing pubspec.yaml: \(error)") + } +} + +let library_version: String +let firebase_sdk_version_string: String +let firebase_core_version_string: String +let shared_spm_tag = "-firebase-core-swift" + +do { + library_version = try loadPubspecVersions().packageVersion + firebase_sdk_version_string = try loadFirebaseSDKVersion() + firebase_core_version_string = try loadPubspecVersions().firebaseCoreVersion +} catch { + fatalError("Failed to load configuration: \(error)") +} + +guard let firebase_sdk_version = Version(firebase_sdk_version_string) else { + fatalError("Invalid Firebase SDK version: \(firebase_sdk_version_string)") +} + +guard let shared_spm_version = Version("\(firebase_core_version_string)\(shared_spm_tag)") else { + fatalError("Invalid firebase_core version: \(firebase_core_version_string)\(shared_spm_tag)") +} + +let package = Package( + name: "firebase_database", + platforms: [ + .iOS("13.0"), + ], + products: [ + .library(name: "firebase-database", targets: ["firebase_database"]), + ], + dependencies: [ + .package(url: "https://github.com/firebase/firebase-ios-sdk", from: firebase_sdk_version), + .package(url: "https://github.com/firebase/flutterfire", exact: shared_spm_version), + ], + targets: [ + .target( + name: "firebase_database", + dependencies: [ + .product(name: "FirebaseDatabase", package: "firebase-ios-sdk"), + // Wrapper dependency + .product(name: "firebase-core-shared", package: "flutterfire"), + ], + resources: [ + .process("Resources"), + ], + cSettings: [ + .headerSearchPath("include"), + .define("LIBRARY_VERSION", to: "\"\(library_version)\""), + .define("LIBRARY_NAME", to: "\"flutter-fire-rtdb\""), + ] + ), + ] +) diff --git a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.m b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseObserveStreamHandler.m similarity index 95% rename from packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.m rename to packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseObserveStreamHandler.m index e1001762137c..2d246c7c089b 100644 --- a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.m +++ b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseObserveStreamHandler.m @@ -3,7 +3,11 @@ // found in the LICENSE file. @import FirebaseDatabase; +#if __has_include() #import +#else +#import +#endif #import "FLTFirebaseDatabaseObserveStreamHandler.h" #import "FLTFirebaseDatabaseUtils.h" diff --git a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabasePlugin.m b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabasePlugin.m similarity index 98% rename from packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabasePlugin.m rename to packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabasePlugin.m index 433333b051cd..bd42988225b8 100644 --- a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabasePlugin.m +++ b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabasePlugin.m @@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#if __has_include() #import +#else +#import +#endif #import "FLTFirebaseDatabaseObserveStreamHandler.h" #import "FLTFirebaseDatabasePlugin.h" @@ -135,11 +139,11 @@ - (NSDictionary *_Nonnull)pluginConstantsForFIRApp:(FIRApp *)firebase_app { } - (NSString *_Nonnull)firebaseLibraryName { - return LIBRARY_NAME; + return @LIBRARY_NAME; } - (NSString *_Nonnull)firebaseLibraryVersion { - return LIBRARY_VERSION; + return @LIBRARY_VERSION; } - (NSString *_Nonnull)flutterChannelName { diff --git a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseUtils.m b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseUtils.m similarity index 98% rename from packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseUtils.m rename to packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseUtils.m index db931bdc5bb0..21c392f02693 100644 --- a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseUtils.m +++ b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseUtils.m @@ -3,7 +3,11 @@ // found in the LICENSE file. #import "FLTFirebaseDatabaseUtils.h" +#if __has_include() #import +#else +#import +#endif @implementation FLTFirebaseDatabaseUtils static __strong NSMutableDictionary *cachedDatabaseInstances = nil; diff --git a/packages/firebase_database/firebase_database/ios/Assets/.gitkeep b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/Resources/.gitkeep similarity index 100% rename from packages/firebase_database/firebase_database/ios/Assets/.gitkeep rename to packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/Resources/.gitkeep diff --git a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.h b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseObserveStreamHandler.h similarity index 93% rename from packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.h rename to packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseObserveStreamHandler.h index 2529fd482847..d761836330f9 100644 --- a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.h +++ b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseObserveStreamHandler.h @@ -1,13 +1,14 @@ // Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -@import FirebaseDatabase; #import #if TARGET_OS_OSX +#import #import #else #import +@import FirebaseDatabase; #endif #import diff --git a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabasePlugin.h b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabasePlugin.h similarity index 72% rename from packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabasePlugin.h rename to packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabasePlugin.h index a624e11746f0..591532786ac6 100644 --- a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabasePlugin.h +++ b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabasePlugin.h @@ -1,15 +1,23 @@ // Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -@import FirebaseDatabase; + +#import + #if TARGET_OS_OSX +#import #import #else #import +@import FirebaseDatabase; #endif #import +#if __has_include() #import +#else +#import +#endif @interface FLTFirebaseDatabasePlugin : FLTFirebasePlugin @end diff --git a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseUtils.h b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseUtils.h similarity index 91% rename from packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseUtils.h rename to packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseUtils.h index f58a39924daa..fb6bc87252c3 100644 --- a/packages/firebase_database/firebase_database/ios/Classes/FLTFirebaseDatabaseUtils.h +++ b/packages/firebase_database/firebase_database/ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseUtils.h @@ -1,7 +1,11 @@ // Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#if TARGET_OS_OSX +#import +#else @import FirebaseDatabase; +#endif #import @interface FLTFirebaseDatabaseUtils : NSObject diff --git a/packages/firebase_database/firebase_database/ios/generated_firebase_sdk_version.txt b/packages/firebase_database/firebase_database/ios/generated_firebase_sdk_version.txt new file mode 100644 index 000000000000..72773deb895e --- /dev/null +++ b/packages/firebase_database/firebase_database/ios/generated_firebase_sdk_version.txt @@ -0,0 +1 @@ +11.4.0 diff --git a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseObserveStreamHandler.h b/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseObserveStreamHandler.h deleted file mode 120000 index 2a79f7999aca..000000000000 --- a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseObserveStreamHandler.h +++ /dev/null @@ -1 +0,0 @@ -../../ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.h \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseObserveStreamHandler.m b/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseObserveStreamHandler.m deleted file mode 120000 index d948596301e5..000000000000 --- a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseObserveStreamHandler.m +++ /dev/null @@ -1 +0,0 @@ -../../ios/Classes/FLTFirebaseDatabaseObserveStreamHandler.m \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabasePlugin.h b/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabasePlugin.h deleted file mode 120000 index 162c8acf049b..000000000000 --- a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabasePlugin.h +++ /dev/null @@ -1 +0,0 @@ -../../ios/Classes/FLTFirebaseDatabasePlugin.h \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabasePlugin.m b/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabasePlugin.m deleted file mode 120000 index cc410098d578..000000000000 --- a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabasePlugin.m +++ /dev/null @@ -1 +0,0 @@ -../../ios/Classes/FLTFirebaseDatabasePlugin.m \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseUtils.h b/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseUtils.h deleted file mode 120000 index 939d52eccfa3..000000000000 --- a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseUtils.h +++ /dev/null @@ -1 +0,0 @@ -../../ios/Classes/FLTFirebaseDatabaseUtils.h \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseUtils.m b/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseUtils.m deleted file mode 120000 index a7125aa60d08..000000000000 --- a/packages/firebase_database/firebase_database/macos/Classes/FLTFirebaseDatabaseUtils.m +++ /dev/null @@ -1 +0,0 @@ -../../ios/Classes/FLTFirebaseDatabaseUtils.m \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/firebase_database.podspec b/packages/firebase_database/firebase_database/macos/firebase_database.podspec index edc574645077..88304c53491e 100755 --- a/packages/firebase_database/firebase_database/macos/firebase_database.podspec +++ b/packages/firebase_database/firebase_database/macos/firebase_database.podspec @@ -43,8 +43,8 @@ Pod::Spec.new do |s| s.authors = 'The Chromium Authors' s.source = { :path => '.' } - s.source_files = 'Classes/**/*.{h,m}' - s.public_header_files = 'Classes/*.h' + s.source_files = 'firebase_database/Sources/firebase_database/**/*.{h,m}' + s.public_header_files = 'firebase_database/Sources/firebase_database/include/*.h' s.platform = :osx, '10.13' @@ -58,7 +58,7 @@ Pod::Spec.new do |s| s.static_framework = true s.pod_target_xcconfig = { - 'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\@\\\"#{library_version}\\\" LIBRARY_NAME=\\@\\\"flutter-fire-rtdb\\\"", + 'GCC_PREPROCESSOR_DEFINITIONS' => "LIBRARY_VERSION=\\\"#{library_version}\\\" LIBRARY_NAME=\\\"flutter-fire-rtdb\\\"", 'DEFINES_MODULE' => 'YES' } end diff --git a/packages/firebase_database/firebase_database/macos/firebase_database/Package.swift b/packages/firebase_database/firebase_database/macos/firebase_database/Package.swift new file mode 100644 index 000000000000..676ac821954e --- /dev/null +++ b/packages/firebase_database/firebase_database/macos/firebase_database/Package.swift @@ -0,0 +1,117 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +// Copyright 2024, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import Foundation +import PackageDescription + +enum ConfigurationError: Error { + case fileNotFound(String) + case parsingError(String) + case invalidFormat(String) +} + +let databaseDirectory = String(URL(string: #file)!.deletingLastPathComponent().absoluteString + .dropLast()) + +func loadFirebaseSDKVersion() throws -> String { + let firebaseCoreScriptPath = NSString.path(withComponents: [ + databaseDirectory, + "..", + "..", + "ios", + "generated_firebase_sdk_version.txt", + ]) + do { + let version = try String(contentsOfFile: firebaseCoreScriptPath, encoding: .utf8) + .trimmingCharacters(in: .whitespacesAndNewlines) + return version + } catch { + throw ConfigurationError + .fileNotFound("Error loading or parsing generated_firebase_sdk_version.txt: \(error)") + } +} + +func loadPubspecVersions() throws -> (packageVersion: String, firebaseCoreVersion: String) { + let pubspecPath = NSString.path(withComponents: [databaseDirectory, "..", "..", "pubspec.yaml"]) + do { + let yamlString = try String(contentsOfFile: pubspecPath, encoding: .utf8) + let lines = yamlString.split(separator: "\n") + + guard let packageVersionLine = lines.first(where: { $0.starts(with: "version:") }) else { + throw ConfigurationError.invalidFormat("No package version line found in pubspec.yaml") + } + var packageVersion = packageVersionLine.split(separator: ":")[1] + .trimmingCharacters(in: .whitespaces) + .replacingOccurrences(of: "+", with: "-") + packageVersion = packageVersion.replacingOccurrences(of: "^", with: "") + + guard let firebaseCoreVersionLine = lines.first(where: { $0.contains("firebase_core:") }) else { + throw ConfigurationError + .invalidFormat("No firebase_core dependency version line found in pubspec.yaml") + } + var firebaseCoreVersion = firebaseCoreVersionLine.split(separator: ":")[1] + .trimmingCharacters(in: .whitespaces) + firebaseCoreVersion = firebaseCoreVersion.replacingOccurrences(of: "^", with: "") + + return (packageVersion, firebaseCoreVersion) + } catch { + throw ConfigurationError.fileNotFound("Error loading or parsing pubspec.yaml: \(error)") + } +} + +let library_version: String +let firebase_sdk_version_string: String +let firebase_core_version_string: String +let shared_spm_tag = "-firebase-core-swift" + +do { + library_version = try loadPubspecVersions().packageVersion + firebase_sdk_version_string = try loadFirebaseSDKVersion() + firebase_core_version_string = try loadPubspecVersions().firebaseCoreVersion +} catch { + fatalError("Failed to load configuration: \(error)") +} + +guard let firebase_sdk_version = Version(firebase_sdk_version_string) else { + fatalError("Invalid Firebase SDK version: \(firebase_sdk_version_string)") +} + +guard let shared_spm_version = Version("\(firebase_core_version_string)\(shared_spm_tag)") else { + fatalError("Invalid firebase_core version: \(firebase_core_version_string)\(shared_spm_tag)") +} + +let package = Package( + name: "firebase_database", + platforms: [ + .macOS("10.15"), + ], + products: [ + .library(name: "firebase-database", targets: ["firebase_database"]), + ], + dependencies: [ + .package(url: "https://github.com/firebase/firebase-ios-sdk", from: firebase_sdk_version), + .package(url: "https://github.com/firebase/flutterfire", exact: shared_spm_version), + ], + targets: [ + .target( + name: "firebase_database", + dependencies: [ + .product(name: "FirebaseDatabase", package: "firebase-ios-sdk"), + // Wrapper dependency + .product(name: "firebase-core-shared", package: "flutterfire"), + ], + resources: [ + .process("Resources"), + ], + cSettings: [ + .headerSearchPath("include"), + .define("LIBRARY_VERSION", to: "\"\(library_version)\""), + .define("LIBRARY_NAME", to: "\"flutter-fire-rtdb\""), + ] + ), + ] +) diff --git a/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseObserveStreamHandler.m b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseObserveStreamHandler.m new file mode 120000 index 000000000000..41fc5db873e5 --- /dev/null +++ b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseObserveStreamHandler.m @@ -0,0 +1 @@ +../../../../ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseObserveStreamHandler.m \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabasePlugin.m b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabasePlugin.m new file mode 120000 index 000000000000..6339b2c27f9d --- /dev/null +++ b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabasePlugin.m @@ -0,0 +1 @@ +../../../../ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabasePlugin.m \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseUtils.m b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseUtils.m new file mode 120000 index 000000000000..095be8555691 --- /dev/null +++ b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseUtils.m @@ -0,0 +1 @@ +../../../../ios/firebase_database/Sources/firebase_database/FLTFirebaseDatabaseUtils.m \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/Assets/.gitkeep b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/Resources/.gitkeep old mode 100755 new mode 100644 similarity index 100% rename from packages/firebase_database/firebase_database/macos/Assets/.gitkeep rename to packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/Resources/.gitkeep diff --git a/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseObserveStreamHandler.h b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseObserveStreamHandler.h new file mode 120000 index 000000000000..9cf1e3969aed --- /dev/null +++ b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseObserveStreamHandler.h @@ -0,0 +1 @@ +../../../../../ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseObserveStreamHandler.h \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabasePlugin.h b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabasePlugin.h new file mode 120000 index 000000000000..117a487a9fed --- /dev/null +++ b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabasePlugin.h @@ -0,0 +1 @@ +../../../../../ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabasePlugin.h \ No newline at end of file diff --git a/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseUtils.h b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseUtils.h new file mode 120000 index 000000000000..a1da140b0f82 --- /dev/null +++ b/packages/firebase_database/firebase_database/macos/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseUtils.h @@ -0,0 +1 @@ +../../../../../ios/firebase_database/Sources/firebase_database/include/FLTFirebaseDatabaseUtils.h \ No newline at end of file