-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(firebase_core): create a swift package of shared iOS source cod…
…e for all plugins (#13540)
- Loading branch information
1 parent
d3cfc0e
commit 7376043
Showing
7 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// 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) | ||
} | ||
|
||
func loadFirebaseSDKVersion() throws -> String { | ||
let firebaseCoreScriptPath = NSString.path(withComponents: [ | ||
"packages", | ||
"firebase_core", | ||
"firebase_core", | ||
"ios", | ||
"firebase_sdk_version.rb", | ||
]) | ||
|
||
do { | ||
let content = try String(contentsOfFile: firebaseCoreScriptPath, encoding: .utf8) | ||
let pattern = #"def firebase_sdk_version!\(\)\n\s+'([^']+)'\nend"# | ||
if let regex = try? NSRegularExpression(pattern: pattern, options: []), | ||
let match = regex.firstMatch( | ||
in: content, | ||
range: NSRange(content.startIndex..., in: content) | ||
) { | ||
if let versionRange = Range(match.range(at: 1), in: content) { | ||
return String(content[versionRange]) | ||
} else { | ||
throw ConfigurationError.invalidFormat("Invalid format in firebase_sdk_version.rb") | ||
} | ||
} else { | ||
throw ConfigurationError.parsingError("No match found in firebase_sdk_version.rb") | ||
} | ||
} catch { | ||
throw ConfigurationError | ||
.fileNotFound("Error loading or parsing firebase_sdk_version.rb: \(error)") | ||
} | ||
} | ||
|
||
let firebase_sdk_version_string: String | ||
|
||
do { | ||
firebase_sdk_version_string = try loadFirebaseSDKVersion() | ||
} 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)") | ||
} | ||
|
||
// Shared Swift package manager code for firebase core | ||
let package = Package( | ||
name: "remote_firebase_core", | ||
platforms: [ | ||
.iOS("13.0"), | ||
.macOS("10.15"), | ||
], | ||
products: [ | ||
.library(name: "firebase-core-shared", targets: ["firebase_core_shared"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/firebase/firebase-ios-sdk", exact: firebase_sdk_version), | ||
], | ||
targets: [ | ||
.target( | ||
name: "firebase_core_shared", | ||
dependencies: [ | ||
.product(name: "FirebaseInstallations", package: "firebase-ios-sdk"), | ||
], | ||
path: "Sources/firebase_core_shared", | ||
publicHeadersPath: "include" | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebasePlugin.m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/FLTFirebasePluginRegistry.m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebasePlugin.h |
1 change: 1 addition & 0 deletions
1
Sources/firebase_core_shared/include/FLTFirebasePluginRegistry.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../packages/firebase_core/firebase_core/ios/firebase_core/Sources/firebase_core/include/firebase_core/FLTFirebasePluginRegistry.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2024 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. | ||
// ignore_for_file: avoid_print | ||
|
||
import 'dart:io'; | ||
import 'package:yaml/yaml.dart'; | ||
|
||
void main(List<String> args) { | ||
// 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; | ||
} | ||
|
||
const packageIdentifier = 'firebase-core-swift'; | ||
|
||
// Generate the tag | ||
final tag = '$version-$packageIdentifier'; | ||
print('Generated tag for firebase core swift: $tag'); | ||
|
||
// Run the git tag command | ||
final result = Process.runSync('git', ['tag', tag]); | ||
|
||
if (result.exitCode == 0) { | ||
print('Git tag created successfully for firebase core swift: $tag'); | ||
} else { | ||
print('Error creating git tag: ${result.stderr}'); | ||
} | ||
} |