From a221222e517decc606e1b9d0c7b7603045394962 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 26 Nov 2024 15:37:08 +0000 Subject: [PATCH 1/8] fix(core): auth also requires FLTFirebaseCorePlugin to be shared --- .../firebase_core_shared/FLTFirebaseCorePlugin.m | 1 + .../include/FLTFirebaseCorePlugin.h | 1 + .../ios/firebase_core/Package.swift | 2 ++ .../firebase_core/FLTFirebaseCorePlugin.m | 16 ++++++++++++++++ .../firebase_core/FLTFirebaseCorePlugin.h | 4 ++++ 5 files changed, 24 insertions(+) create mode 120000 Sources/firebase_core_shared/FLTFirebaseCorePlugin.m create mode 120000 Sources/firebase_core_shared/include/FLTFirebaseCorePlugin.h diff --git a/Sources/firebase_core_shared/FLTFirebaseCorePlugin.m b/Sources/firebase_core_shared/FLTFirebaseCorePlugin.m new file mode 120000 index 000000000000..e94afa3aad20 --- /dev/null +++ b/Sources/firebase_core_shared/FLTFirebaseCorePlugin.m @@ -0,0 +1 @@ +../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m \ No newline at end of file diff --git a/Sources/firebase_core_shared/include/FLTFirebaseCorePlugin.h b/Sources/firebase_core_shared/include/FLTFirebaseCorePlugin.h new file mode 120000 index 000000000000..8e3a8c248b88 --- /dev/null +++ b/Sources/firebase_core_shared/include/FLTFirebaseCorePlugin.h @@ -0,0 +1 @@ +../../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h \ No newline at end of file diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift b/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift index a39f10863fc1..2a27adeedb68 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift @@ -109,8 +109,10 @@ let package = Package( ], exclude: [ // These are now pulled in as a remote dependency from FlutterFire repo + "FLTFirebaseCorePlugin.m", "FLTFirebasePlugin.m", "FLTFirebasePluginRegistry.m", + "include/firebase_core/FLTFirebaseCorePlugin.h", "include/firebase_core/FLTFirebasePlugin.h", "include/firebase_core/FLTFirebasePluginRegistry.h", ], diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m index 87cb647c0eba..0ef999ebdc02 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m @@ -2,9 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +#if __has_include("include/firebase_core/FLTFirebaseCorePlugin.h") #import "include/firebase_core/FLTFirebaseCorePlugin.h" +#else +#import "include/FLTFirebaseCorePlugin.h" +#endif + +#if __has_include("include/firebase_core/FLTFirebasePluginRegistry.h") #import "include/firebase_core/FLTFirebasePluginRegistry.h" +#else +#import "include/FLTFirebasePluginRegistry.h" +#endif + +#if __has_include("include/firebase_core/messages.g.h") #import "include/firebase_core/messages.g.h" +#else +#import "include/messages.g.h" +#endif + @implementation FLTFirebaseCorePlugin { BOOL _coreInitialized; diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h index ee051e39baac..accb377c7b46 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h @@ -10,7 +10,11 @@ #endif #import "FLTFirebasePlugin.h" +#if __has_include("include/messages.g.h") +#import "include/messages.g.h" +#else #import "messages.g.h" +#endif @interface FLTFirebaseCorePlugin : FLTFirebasePlugin From 8102c782316cc0597660ce0ca8f39c9972e11e18 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Tue, 26 Nov 2024 15:57:02 +0000 Subject: [PATCH 2/8] chore: format --- .../firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m index 0ef999ebdc02..2fbb803dd8ad 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebaseCorePlugin.m @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - #if __has_include("include/firebase_core/FLTFirebaseCorePlugin.h") #import "include/firebase_core/FLTFirebaseCorePlugin.h" #else @@ -21,7 +20,6 @@ #import "include/messages.g.h" #endif - @implementation FLTFirebaseCorePlugin { BOOL _coreInitialized; } From 22b44de9b804bf39bcce74e601c9ec2d1f1306bb Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 4 Dec 2024 10:27:11 +0000 Subject: [PATCH 3/8] move messages and create dummy files --- Sources/firebase_core_shared/include/messages.g.h | 1 + Sources/firebase_core_shared/messages.g.m | 1 + .../ios/firebase_core/Sources/firebase_core/dummy.m | 0 .../Sources/firebase_core/include/firebase_core/dummy.h | 0 4 files changed, 2 insertions(+) create mode 120000 Sources/firebase_core_shared/include/messages.g.h create mode 120000 Sources/firebase_core_shared/messages.g.m create mode 100644 packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/dummy.m create mode 100644 packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/dummy.h diff --git a/Sources/firebase_core_shared/include/messages.g.h b/Sources/firebase_core_shared/include/messages.g.h new file mode 120000 index 000000000000..3a5ff91b8660 --- /dev/null +++ b/Sources/firebase_core_shared/include/messages.g.h @@ -0,0 +1 @@ +../../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/messages.g.h \ No newline at end of file diff --git a/Sources/firebase_core_shared/messages.g.m b/Sources/firebase_core_shared/messages.g.m new file mode 120000 index 000000000000..9b2e6e36e348 --- /dev/null +++ b/Sources/firebase_core_shared/messages.g.m @@ -0,0 +1 @@ +../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m \ No newline at end of file diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/dummy.m b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/dummy.m new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/dummy.h b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/dummy.h new file mode 100644 index 000000000000..e69de29bb2d1 From 6ad514234e919481a6f496927e19f7977d9ad7d3 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 4 Dec 2024 13:44:56 +0000 Subject: [PATCH 4/8] latest way of getting shared core requires getting everything --- Package.swift | 13 +++- .../ios/firebase_core/Package.swift | 2 + .../firebase_core/FLTFirebaseCorePlugin.h | 6 +- .../Sources/firebase_core/messages.g.m | 5 ++ scripts/generate_ios_sdk_version_txt_spm.dart | 67 +++++++++++++++++++ 5 files changed, 88 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index 1b7b87ce483b..b7d1c2827604 100644 --- a/Package.swift +++ b/Package.swift @@ -8,6 +8,10 @@ import Foundation import PackageDescription +// auto-generated by melos post commit hook script +let firebase_core_version: String = "3.8.0" +let firebase_ios_sdk_version: String = "11.4.0" + // Shared Swift package manager code for firebase core let package = Package( name: "remote_firebase_core", @@ -21,7 +25,7 @@ let package = Package( dependencies: [ // TODO: this is fine for now, but will require a way of retrieving the firebase-ios-sdk // likely create a script that runs in preCommit hook of melos - .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "11.0.0"), + .package(url: "https://github.com/firebase/firebase-ios-sdk", from: Version(firebase_ios_sdk_version)!), ], targets: [ .target( @@ -30,7 +34,12 @@ let package = Package( .product(name: "FirebaseInstallations", package: "firebase-ios-sdk"), ], path: "Sources/firebase_core_shared", - publicHeadersPath: "include" + publicHeadersPath: "include", + cSettings: [ + .headerSearchPath("include/firebase_core"), + .define("LIBRARY_VERSION", to: "\"\(firebase_core_version)\""), + .define("LIBRARY_NAME", to: "\"flutter-fire-core\"") + ] ), ] ) diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift b/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift index 2a27adeedb68..9882bff1cab5 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Package.swift @@ -112,7 +112,9 @@ let package = Package( "FLTFirebaseCorePlugin.m", "FLTFirebasePlugin.m", "FLTFirebasePluginRegistry.m", + "messages.g.m", "include/firebase_core/FLTFirebaseCorePlugin.h", + "include/firebase_core/messages.g.h", "include/firebase_core/FLTFirebasePlugin.h", "include/firebase_core/FLTFirebasePluginRegistry.h", ], diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h index accb377c7b46..3b44f8e75f16 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h @@ -10,10 +10,10 @@ #endif #import "FLTFirebasePlugin.h" -#if __has_include("include/messages.g.h") -#import "include/messages.g.h" +#if __has_include("include/firebase_core/messages.g.h") +#import "include/firebase_core/messages.g.h" #else -#import "messages.g.h" +#import "include/messages.g.h" #endif @interface FLTFirebaseCorePlugin diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m index a1bf4e0fbeb0..e1ce2288c6bd 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m @@ -4,7 +4,12 @@ // Autogenerated from Pigeon (v9.2.5), do not edit directly. // See also: https://pub.dev/packages/pigeon + +#if __has_include("include/firebase_core/messages.g.h") #import "include/firebase_core/messages.g.h" +#else +#import "include/messages.g.h" +#endif #if TARGET_OS_OSX #import #else diff --git a/scripts/generate_ios_sdk_version_txt_spm.dart b/scripts/generate_ios_sdk_version_txt_spm.dart index 9dd55bdde5f5..99c8a1e461aa 100644 --- a/scripts/generate_ios_sdk_version_txt_spm.dart +++ b/scripts/generate_ios_sdk_version_txt_spm.dart @@ -6,6 +6,7 @@ import 'package:melos/melos.dart' as melos; import 'package:glob/glob.dart'; import 'dart:io'; import 'package:cli_util/cli_logging.dart' as logging; +import 'package:yaml/yaml.dart'; // Used to generate a simple txt file for Package.swift file to parse in order to use correct firebase-ios-sdk version @@ -33,6 +34,8 @@ void main(List args) async { versionFile.writeAsStringSync(firebaseiOSVersion); } } + // Update the versions in root Package.swift + updateSharedCoreVersion(firebaseiOSVersion); } Future getMelosWorkspace() async { @@ -69,3 +72,67 @@ String getFirebaseiOSVersion(File firebaseCoreIosSdkVersion) { throw Exception('firebase_sdk_version.rb file does not exist.'); } } + +void updateSharedCoreVersion(String firebaseiOSVersion) { + // Define the path to the pubspec.yaml file + const pubspecPath = 'packages/firebase_core/firebase_core/pubspec.yaml'; + + + // Read the pubspec.yaml file + final pubspecFile = File(pubspecPath); + if (!pubspecFile.existsSync()) { + print('Error: pubspec.yaml file not found at $pubspecPath'); + return; + } + + + // Parse the YAML content + final pubspecContent = pubspecFile.readAsStringSync(); + final pubspecYaml = loadYaml(pubspecContent); + + + // Extract the version + final version = pubspecYaml['version']; + if (version == null) { + print('Error: Version not found in pubspec.yaml'); + return; + } + + + // Define the path to the Package.swift file + const packageSwiftPath = 'Package.swift'; + + + // Read the Package.swift file + final packageSwiftFile = File(packageSwiftPath); + if (!packageSwiftFile.existsSync()) { + print('Error: Package.swift file not found at $packageSwiftPath'); + return; + } + + + // Read the content of Package.swift + final packageSwiftContent = packageSwiftFile.readAsStringSync(); + + + // Update the library_version_string with the new version + final updatedFirebaseCoreVersion = packageSwiftContent.replaceAll( + RegExp('let firebase_core_version: String = "[^"]+"'), + 'let firebase_core_version: String = "$version"', + ); + + + final updatedFirebaseIosVersion = updatedFirebaseCoreVersion.replaceAll( + RegExp('let firebase_ios_sdk_version: String = "[^"]+"'), + 'let firebase_ios_sdk_version: String = "$firebaseiOSVersion"', + ); + + + // Write the updated content back to Package.swift + packageSwiftFile.writeAsStringSync(updatedFirebaseIosVersion); + + + print( + 'Updated Package.swift with firebase_core version: $version & firebase-ios-sdk version: $firebaseiOSVersion', + ); +} From 60c6ab17534c71f03ca6fd36ae305e09fe7f4dbc Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 4 Dec 2024 13:48:03 +0000 Subject: [PATCH 5/8] rename more appropriately --- melos.yaml | 2 +- ...os_sdk_version_txt_spm.dart => generate_versions_spm.dart} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename scripts/{generate_ios_sdk_version_txt_spm.dart => generate_versions_spm.dart} (97%) diff --git a/melos.yaml b/melos.yaml index a12d8e47d9b6..a04e3758f5e5 100644 --- a/melos.yaml +++ b/melos.yaml @@ -19,7 +19,7 @@ command: preCommit: | dart run scripts/generate_vertexai_version.dart && \ dart run scripts/generate_dataconnect_version.dart && \ - dart run scripts/generate_ios_sdk_version_txt_spm.dart && \ + dart run scripts/generate_versions_spm.dart && \ git add packages/firebase_vertexai/firebase_vertexai/lib/src/vertex_version.dart && \ git add packages/firebase_data_connect/firebase_data_connect/lib/src/dataconnect_version.dart post: | diff --git a/scripts/generate_ios_sdk_version_txt_spm.dart b/scripts/generate_versions_spm.dart similarity index 97% rename from scripts/generate_ios_sdk_version_txt_spm.dart rename to scripts/generate_versions_spm.dart index 99c8a1e461aa..6bcb7d9f716f 100644 --- a/scripts/generate_ios_sdk_version_txt_spm.dart +++ b/scripts/generate_versions_spm.dart @@ -35,7 +35,7 @@ void main(List args) async { } } // Update the versions in root Package.swift - updateSharedCoreVersion(firebaseiOSVersion); + updateVersionsPackageSwift(firebaseiOSVersion); } Future getMelosWorkspace() async { @@ -73,7 +73,7 @@ String getFirebaseiOSVersion(File firebaseCoreIosSdkVersion) { } } -void updateSharedCoreVersion(String firebaseiOSVersion) { +void updateVersionsPackageSwift(String firebaseiOSVersion) { // Define the path to the pubspec.yaml file const pubspecPath = 'packages/firebase_core/firebase_core/pubspec.yaml'; From 1138ad12190a3bc7ed0a845f5d7bbc9e73670871 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 4 Dec 2024 14:01:31 +0000 Subject: [PATCH 6/8] fix: import --- .../include/firebase_core/FLTFirebaseCorePlugin.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h index 3b44f8e75f16..accb377c7b46 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebaseCorePlugin.h @@ -10,10 +10,10 @@ #endif #import "FLTFirebasePlugin.h" -#if __has_include("include/firebase_core/messages.g.h") -#import "include/firebase_core/messages.g.h" -#else +#if __has_include("include/messages.g.h") #import "include/messages.g.h" +#else +#import "messages.g.h" #endif @interface FLTFirebaseCorePlugin From 9f186aaf18753c7b5bda003f3250dfcc319e925c Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 4 Dec 2024 14:01:59 +0000 Subject: [PATCH 7/8] format --- Package.swift | 7 +++++-- .../ios/firebase_core/Sources/firebase_core/messages.g.m | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index b7d1c2827604..99d13a6fe95c 100644 --- a/Package.swift +++ b/Package.swift @@ -25,7 +25,10 @@ let package = Package( dependencies: [ // TODO: this is fine for now, but will require a way of retrieving the firebase-ios-sdk // likely create a script that runs in preCommit hook of melos - .package(url: "https://github.com/firebase/firebase-ios-sdk", from: Version(firebase_ios_sdk_version)!), + .package( + url: "https://github.com/firebase/firebase-ios-sdk", + from: Version(firebase_ios_sdk_version)! + ), ], targets: [ .target( @@ -38,7 +41,7 @@ let package = Package( cSettings: [ .headerSearchPath("include/firebase_core"), .define("LIBRARY_VERSION", to: "\"\(firebase_core_version)\""), - .define("LIBRARY_NAME", to: "\"flutter-fire-core\"") + .define("LIBRARY_NAME", to: "\"flutter-fire-core\""), ] ), ] diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m index e1ce2288c6bd..631f1932432f 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/messages.g.m @@ -4,7 +4,6 @@ // Autogenerated from Pigeon (v9.2.5), do not edit directly. // See also: https://pub.dev/packages/pigeon - #if __has_include("include/firebase_core/messages.g.h") #import "include/firebase_core/messages.g.h" #else From 806f300e8be8579a7d2ba6837fc86020e89c9c03 Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Wed, 4 Dec 2024 14:04:04 +0000 Subject: [PATCH 8/8] license headers --- .../ios/firebase_core/Sources/firebase_core/dummy.m | 3 +++ .../Sources/firebase_core/include/firebase_core/dummy.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/dummy.m b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/dummy.m index e69de29bb2d1..b26e56855988 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/dummy.m +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/dummy.m @@ -0,0 +1,3 @@ +// Copyright 2023, 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. diff --git a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/dummy.h b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/dummy.h index e69de29bb2d1..b26e56855988 100644 --- a/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/dummy.h +++ b/packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/dummy.h @@ -0,0 +1,3 @@ +// Copyright 2023, 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.