Skip to content

Commit

Permalink
Update Carthage for new Zip layout (#4494)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Dec 13, 2019
1 parent 624e762 commit a99f969
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions ZipBuilder/Sources/ZipBuilder/CarthageUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ extension CarthageUtils {
jsonManifest[firebaseVersion] = url

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

// Unfortunate workaround: There's a strange issue when serializing to JSON on macOS: URLs
// will have the `/` escaped leading to an odd JSON output. Instead, let's output the
Expand Down Expand Up @@ -256,7 +256,7 @@ extension CarthageUtils {
/// - Returns: A dictionary with versions as keys and URLs as values.
private static func parseJSONFile(fromDir dir: URL, product: String) -> [String: URL] {
// Parse the JSON manifest.
let jsonFileName = "Firebase\(product)Binary.json"
let jsonFileName = getJSONFileName(product: product)
let jsonFile = dir.appendingPathComponent(jsonFileName)
guard FileManager.default.fileExists(atPath: jsonFile.path) else {
fatalError("Could not find JSON manifest for \(product) during Carthage build. " +
Expand All @@ -281,4 +281,22 @@ extension CarthageUtils {
"Location: \(jsonFile). \(error)")
}
}

/// Get the JSON filename for a product
/// Consider using just the product name post Firebase 7. The conditions are to handle Firebase 6 compatibility.
///
/// - Parameters:
/// - product: The name of the Firebase product.
/// - Returns: JSON file name for a product.
private static func getJSONFileName(product: String) -> String {
var jsonFileName: String
if product == "GoogleSignIn" {
jsonFileName = "FirebaseGoogleSignIn"
} else if product == "Google-Mobile-Ads-SDK" {
jsonFileName = "FirebaseAdMob"
} else {
jsonFileName = product
}
return jsonFileName + "Binary.json"
}
}

0 comments on commit a99f969

Please sign in to comment.