Skip to content

Commit c0130d8

Browse files
authored
Add Info.plist to Carthage binary frameworks (#6445)
1 parent a7b4349 commit c0130d8

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

FirebaseCore/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- [fixed] Swift Package Manager - Define system framework and system library dependencies. This
33
resolves undefined symbol issues for system dependencies. (#6408, #6413)
44
- [fixed] Enable Firebase pod support for Auth and Crashlytics watchOS platform. (#4558)
5+
- [fixed] Carthage - Some frameworks were missing Info.plist files. (#5562)
56

67
# Firebase 6.32.0
78
- [changed] Swift Package Manager - It's no longer necessary to select the Firebase or

ZipBuilder/Sources/ZipBuilder/CarthageUtils.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,10 @@ extension CarthageUtils {
280280
}
281281

282282
// Write the Info.plist.
283-
let data = generatePlistContents(forName: "Firebase")
284-
do { try data.write(to: frameworkDir.appendingPathComponent("Info.plist")) }
285-
catch {
286-
fatalError("Could not write the Info.plist for Firebase framework in Carthage. \(error)")
287-
}
283+
generatePlistContents(forName: "Firebase", to: frameworkDir)
288284
}
289285

290-
static func generatePlistContents(forName name: String) -> Data {
286+
static func generatePlistContents(forName name: String, to location: URL) {
291287
let plist: [String: String] = ["CFBundleIdentifier": "com.firebase.Firebase-\(name)",
292288
"CFBundleInfoDictionaryVersion": "6.0",
293289
"CFBundlePackageType": "FMWK",
@@ -300,7 +296,8 @@ extension CarthageUtils {
300296
let encoder = PropertyListEncoder()
301297
encoder.outputFormat = .xml
302298
do {
303-
return try encoder.encode(plist)
299+
let data = try encoder.encode(plist)
300+
try data.write(to: location.appendingPathComponent("Info.plist"))
304301
} catch {
305302
fatalError("Failed to create Info.plist for \(name) during Carthage build: \(error)")
306303
}

ZipBuilder/Sources/ZipBuilder/FrameworkBuilder.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,8 @@ struct FrameworkBuilder {
810810
return xcframework
811811
}
812812

813-
/// Packages a Carthage framework. Carthage does not yet support xcframeworks, so we exclude the Catalyst slice.
813+
/// Packages a Carthage framework. Carthage does not yet support xcframeworks, so we exclude the
814+
/// Catalyst slice.
814815
/// - Parameter withName: The framework name.
815816
/// - Parameter fromFolder: The almost complete framework folder. Includes everything but the binary.
816817
/// - Parameter thinArchives: All the thin archives.
@@ -846,14 +847,7 @@ struct FrameworkBuilder {
846847
moduleMapContents: moduleMapContents)
847848

848849
// Add Info.plist frameworks to make Carthage happy.
849-
let plistPath = frameworkDir.appendingPathComponents(["Info.plist"])
850-
// Drop the extension of the framework name.
851-
let plist = CarthageUtils.generatePlistContents(forName: framework)
852-
do {
853-
try plist.write(to: plistPath)
854-
} catch {
855-
fatalError("Could not copy plist for \(frameworkDir) for Carthage release. \(error)")
856-
}
850+
CarthageUtils.generatePlistContents(forName: framework, to: frameworkDir)
857851

858852
// Carthage Resources are packaged in the framework.
859853
let resourceDir = frameworkDir.appendingPathComponent("Resources")

ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -664,14 +664,17 @@ struct ZipBuilder {
664664

665665
// Create the temporary directory we'll be storing the build/assembled frameworks in, and remove
666666
// the Resources directory if it already exists.
667-
let tempDir = fileManager.temporaryDirectory(withName: "all_frameworks")
667+
let binaryZipDir = fileManager.temporaryDirectory(withName: "binary_zip")
668+
let binaryCarthageDir = fileManager.temporaryDirectory(withName: "binary_carthage")
668669
do {
669-
try fileManager.createDirectory(at: tempDir,
670+
try fileManager.createDirectory(at: binaryZipDir,
671+
withIntermediateDirectories: true,
672+
attributes: nil)
673+
try fileManager.createDirectory(at: binaryCarthageDir,
670674
withIntermediateDirectories: true,
671675
attributes: nil)
672676
} catch {
673-
fatalError("Cannot create temporary directory to store frameworks from the " +
674-
"full build: \(error)")
677+
fatalError("Cannot create temporary directory to store binary frameworks: \(error)")
675678
}
676679

677680
// Loop through each pod folder and check if the frameworks already exist, or they need to be
@@ -710,19 +713,27 @@ struct ZipBuilder {
710713
// Copy each of the frameworks to a known temporary directory and store the location.
711714
for framework in podInfo.binaryFrameworks {
712715
// Copy it to the temporary directory and save it to our list of frameworks.
713-
let copiedLocation = tempDir.appendingPathComponent(framework.lastPathComponent)
716+
let zipLocation = binaryZipDir.appendingPathComponent(framework.lastPathComponent)
717+
let carthageLocation =
718+
binaryCarthageDir.appendingPathComponent(framework.lastPathComponent)
714719

715720
// Remove the framework if it exists since it could be out of date.
716-
fileManager.removeIfExists(at: copiedLocation)
721+
fileManager.removeIfExists(at: zipLocation)
722+
fileManager.removeIfExists(at: carthageLocation)
717723
do {
718-
try fileManager.copyItem(at: framework, to: copiedLocation)
724+
try fileManager.copyItem(at: framework, to: zipLocation)
725+
try fileManager.copyItem(at: framework, to: carthageLocation)
719726
} catch {
720-
fatalError("Cannot copy framework at \(framework) to \(copiedLocation) while " +
727+
fatalError("Cannot copy framework at \(framework) while " +
721728
"attempting to generate frameworks. \(error)")
722729
}
723-
frameworks.append(copiedLocation)
724-
// Same while both closed source and Carthage don't support xcframeworks.
725-
carthageFrameworks.append(copiedLocation)
730+
frameworks.append(zipLocation)
731+
732+
CarthageUtils.generatePlistContents(
733+
forName: framework.lastPathComponent.components(separatedBy: ".").first!,
734+
to: carthageLocation
735+
)
736+
carthageFrameworks.append(carthageLocation)
726737
}
727738
}
728739
toInstall[podName] = frameworks

0 commit comments

Comments
 (0)