Skip to content

Commit a99f969

Browse files
authored
Update Carthage for new Zip layout (#4494)
1 parent 624e762 commit a99f969

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ZipBuilder/Sources/ZipBuilder/CarthageUtils.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ extension CarthageUtils {
134134
jsonManifest[firebaseVersion] = url
135135

136136
// Write the updated manifest.
137-
let manifestPath = outputDir.appendingPathComponent("Firebase" + product + "Binary.json")
137+
let manifestPath = outputDir.appendingPathComponent(getJSONFileName(product: product))
138138

139139
// Unfortunate workaround: There's a strange issue when serializing to JSON on macOS: URLs
140140
// will have the `/` escaped leading to an odd JSON output. Instead, let's output the
@@ -256,7 +256,7 @@ extension CarthageUtils {
256256
/// - Returns: A dictionary with versions as keys and URLs as values.
257257
private static func parseJSONFile(fromDir dir: URL, product: String) -> [String: URL] {
258258
// Parse the JSON manifest.
259-
let jsonFileName = "Firebase\(product)Binary.json"
259+
let jsonFileName = getJSONFileName(product: product)
260260
let jsonFile = dir.appendingPathComponent(jsonFileName)
261261
guard FileManager.default.fileExists(atPath: jsonFile.path) else {
262262
fatalError("Could not find JSON manifest for \(product) during Carthage build. " +
@@ -281,4 +281,22 @@ extension CarthageUtils {
281281
"Location: \(jsonFile). \(error)")
282282
}
283283
}
284+
285+
/// Get the JSON filename for a product
286+
/// Consider using just the product name post Firebase 7. The conditions are to handle Firebase 6 compatibility.
287+
///
288+
/// - Parameters:
289+
/// - product: The name of the Firebase product.
290+
/// - Returns: JSON file name for a product.
291+
private static func getJSONFileName(product: String) -> String {
292+
var jsonFileName: String
293+
if product == "GoogleSignIn" {
294+
jsonFileName = "FirebaseGoogleSignIn"
295+
} else if product == "Google-Mobile-Ads-SDK" {
296+
jsonFileName = "FirebaseAdMob"
297+
} else {
298+
jsonFileName = product
299+
}
300+
return jsonFileName + "Binary.json"
301+
}
284302
}

0 commit comments

Comments
 (0)