Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Info.plist to Carthage binary frameworks #6445

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions FirebaseCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- [fixed] Swift Package Manager - Define system framework and system library dependencies. This
resolves undefined symbol issues for system dependencies. (#6408, #6413)
- [fixed] Enable Firebase pod support for Auth and Crashlytics watchOS platform. (#4558)
- [fixed] Carthage - Some frameworks were missing Info.plist files. (#5562)

# Firebase 6.32.0
- [changed] Swift Package Manager - It's no longer necessary to select the Firebase or
Expand Down
11 changes: 4 additions & 7 deletions ZipBuilder/Sources/ZipBuilder/CarthageUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,10 @@ extension CarthageUtils {
}

// Write the Info.plist.
let data = generatePlistContents(forName: "Firebase")
do { try data.write(to: frameworkDir.appendingPathComponent("Info.plist")) }
catch {
fatalError("Could not write the Info.plist for Firebase framework in Carthage. \(error)")
}
generatePlistContents(forName: "Firebase", to: frameworkDir)
}

static func generatePlistContents(forName name: String) -> Data {
static func generatePlistContents(forName name: String, to location: URL) {
let plist: [String: String] = ["CFBundleIdentifier": "com.firebase.Firebase-\(name)",
"CFBundleInfoDictionaryVersion": "6.0",
"CFBundlePackageType": "FMWK",
Expand All @@ -300,7 +296,8 @@ extension CarthageUtils {
let encoder = PropertyListEncoder()
encoder.outputFormat = .xml
do {
return try encoder.encode(plist)
let data = try encoder.encode(plist)
try data.write(to: location.appendingPathComponent("Info.plist"))
} catch {
fatalError("Failed to create Info.plist for \(name) during Carthage build: \(error)")
}
Expand Down
12 changes: 3 additions & 9 deletions ZipBuilder/Sources/ZipBuilder/FrameworkBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,8 @@ struct FrameworkBuilder {
return xcframework
}

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

// Add Info.plist frameworks to make Carthage happy.
let plistPath = frameworkDir.appendingPathComponents(["Info.plist"])
// Drop the extension of the framework name.
let plist = CarthageUtils.generatePlistContents(forName: framework)
do {
try plist.write(to: plistPath)
} catch {
fatalError("Could not copy plist for \(frameworkDir) for Carthage release. \(error)")
}
CarthageUtils.generatePlistContents(forName: framework, to: frameworkDir)

// Carthage Resources are packaged in the framework.
let resourceDir = frameworkDir.appendingPathComponent("Resources")
Expand Down
33 changes: 22 additions & 11 deletions ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -664,14 +664,17 @@ struct ZipBuilder {

// Create the temporary directory we'll be storing the build/assembled frameworks in, and remove
// the Resources directory if it already exists.
let tempDir = fileManager.temporaryDirectory(withName: "all_frameworks")
let binaryZipDir = fileManager.temporaryDirectory(withName: "binary_zip")
let binaryCarthageDir = fileManager.temporaryDirectory(withName: "binary_carthage")
do {
try fileManager.createDirectory(at: tempDir,
try fileManager.createDirectory(at: binaryZipDir,
withIntermediateDirectories: true,
attributes: nil)
try fileManager.createDirectory(at: binaryCarthageDir,
withIntermediateDirectories: true,
attributes: nil)
} catch {
fatalError("Cannot create temporary directory to store frameworks from the " +
"full build: \(error)")
fatalError("Cannot create temporary directory to store binary frameworks: \(error)")
}

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

// Remove the framework if it exists since it could be out of date.
fileManager.removeIfExists(at: copiedLocation)
fileManager.removeIfExists(at: zipLocation)
fileManager.removeIfExists(at: carthageLocation)
do {
try fileManager.copyItem(at: framework, to: copiedLocation)
try fileManager.copyItem(at: framework, to: zipLocation)
try fileManager.copyItem(at: framework, to: carthageLocation)
} catch {
fatalError("Cannot copy framework at \(framework) to \(copiedLocation) while " +
fatalError("Cannot copy framework at \(framework) while " +
"attempting to generate frameworks. \(error)")
}
frameworks.append(copiedLocation)
// Same while both closed source and Carthage don't support xcframeworks.
carthageFrameworks.append(copiedLocation)
frameworks.append(zipLocation)

CarthageUtils.generatePlistContents(
forName: framework.lastPathComponent.components(separatedBy: ".").first!,
to: carthageLocation
)
carthageFrameworks.append(carthageLocation)
}
}
toInstall[podName] = frameworks
Expand Down