|
5 | 5 | // for details. All rights reserved. Use of this source code is governed by a |
6 | 6 | // BSD-style license that can be found in the LICENSE file. |
7 | 7 |
|
8 | | -import Foundation |
9 | 8 | import PackageDescription |
10 | 9 |
|
11 | | -enum ConfigurationError: Error { |
12 | | - case fileNotFound(String) |
13 | | - case parsingError(String) |
14 | | - case invalidFormat(String) |
15 | | -} |
16 | | - |
17 | | -let firestoreDirectory = String(URL(string: #file)!.deletingLastPathComponent().absoluteString |
18 | | - .dropLast()) |
19 | | - |
20 | | -func loadFirebaseSDKVersion() throws -> String { |
21 | | - let firebaseCoreScriptPath = NSString.path(withComponents: [ |
22 | | - firestoreDirectory, |
23 | | - "..", |
24 | | - "generated_firebase_sdk_version.txt", |
25 | | - ]) |
26 | | - do { |
27 | | - return try String(contentsOfFile: firebaseCoreScriptPath, encoding: .utf8) |
28 | | - .trimmingCharacters(in: .whitespacesAndNewlines) |
29 | | - } catch { |
30 | | - throw ConfigurationError |
31 | | - .fileNotFound("Error loading or parsing generated_firebase_sdk_version.txt: \(error)") |
32 | | - } |
33 | | -} |
34 | | - |
35 | | -func loadPubspecVersions() throws -> (packageVersion: String, firebaseCoreVersion: String) { |
36 | | - let pubspecPath = NSString.path(withComponents: [firestoreDirectory, "..", "..", "pubspec.yaml"]) |
37 | | - do { |
38 | | - let yamlString = try String(contentsOfFile: pubspecPath, encoding: .utf8) |
39 | | - let lines = yamlString.split(separator: "\n") |
40 | | - |
41 | | - guard let packageVersionLine = lines.first(where: { $0.starts(with: "version:") }) else { |
42 | | - throw ConfigurationError.invalidFormat("No package version line found in pubspec.yaml") |
43 | | - } |
44 | | - var packageVersion = packageVersionLine.split(separator: ":")[1] |
45 | | - .trimmingCharacters(in: .whitespaces) |
46 | | - .replacingOccurrences(of: "+", with: "-") |
47 | | - packageVersion = packageVersion.replacingOccurrences(of: "^", with: "") |
48 | | - |
49 | | - guard let firebaseCoreVersionLine = lines.first(where: { $0.contains("firebase_core:") }) else { |
50 | | - throw ConfigurationError |
51 | | - .invalidFormat("No firebase_core dependency version line found in pubspec.yaml") |
52 | | - } |
53 | | - var firebaseCoreVersion = firebaseCoreVersionLine.split(separator: ":")[1] |
54 | | - .trimmingCharacters(in: .whitespaces) |
55 | | - firebaseCoreVersion = firebaseCoreVersion.replacingOccurrences(of: "^", with: "") |
56 | | - |
57 | | - return (packageVersion, firebaseCoreVersion) |
58 | | - } catch { |
59 | | - throw ConfigurationError.fileNotFound("Error loading or parsing pubspec.yaml: \(error)") |
60 | | - } |
61 | | -} |
62 | | - |
63 | | -let library_version: String |
64 | | -let firebase_sdk_version_string: String |
65 | | -let firebase_core_version_string: String |
66 | | -let shared_spm_tag = "-firebase-core-swift" |
67 | | - |
68 | | -do { |
69 | | - library_version = try loadPubspecVersions().packageVersion |
70 | | - firebase_sdk_version_string = try loadFirebaseSDKVersion() |
71 | | - firebase_core_version_string = try loadPubspecVersions().firebaseCoreVersion |
72 | | -} catch { |
73 | | - fatalError("Failed to load configuration: \(error)") |
74 | | -} |
75 | | - |
76 | | -guard let firebase_sdk_version = Version(firebase_sdk_version_string) else { |
77 | | - fatalError("Invalid Firebase SDK version: \(firebase_sdk_version_string)") |
78 | | -} |
79 | | - |
80 | | -guard let shared_spm_version = Version("\(firebase_core_version_string)\(shared_spm_tag)") else { |
81 | | - fatalError("Invalid firebase_core version: \(firebase_core_version_string)\(shared_spm_tag)") |
82 | | -} |
| 10 | +let library_version = "6.1.3" |
| 11 | +let firebase_sdk_version = Version("12.9.0")! |
| 12 | +let shared_spm_version = Version("4.5.0-firebase-core-swift")! |
83 | 13 |
|
84 | 14 | let package = Package( |
85 | 15 | name: "cloud_firestore", |
|
0 commit comments