Skip to content

Commit d5e197d

Browse files
ryanwilsonpaulb777
authored andcommitted
Overwrite CoreDiagnostics framework with framework passed in. (#2560)
1 parent 9502e8d commit d5e197d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,33 @@ struct ZipBuilder {
209209
// Create an array that has the Pod name as the key and the array of frameworks needed - this
210210
// will be used as the source of truth for all frameworks to be copied in each product's
211211
// directory.
212-
let frameworks = filesToInstall.mapValues { $0.frameworks }
212+
var frameworks = filesToInstall.mapValues { $0.frameworks }
213213
for (framework, paths) in frameworks {
214214
print("Frameworks for pod: \(framework) were compiled at \(paths)")
215215
}
216216

217-
// TODO: Overwrite the `CoreDiagnostics.framework` in the generated framework.
217+
// Overwrite the `FirebaseCoreDiagnostics.framework` in the `FirebaseAnalytics` folder. This is
218+
// needed because it was compiled specifically with the `ZIP` bit enabled, helping us understand
219+
// the distribution of CocoaPods vs Zip file integrations.
220+
if subspecsToInstall.contains(.analytics) {
221+
let overriddenAnalytics: [URL] = {
222+
guard let currentFrameworks = frameworks["FirebaseAnalytics"] else {
223+
fatalError("Attempted to replace CoreDiagnostics framework but the FirebaseAnalytics " +
224+
"directory does not exist. Existing directories: \(frameworks.keys)")
225+
}
226+
227+
// Filter out any CoreDiagnostics directories from the frameworks to install. There should
228+
// only be one.
229+
let withoutDiagnostics: [URL] = currentFrameworks.filter { url in
230+
url.lastPathComponent != "FirebaseCoreDiagnostics.framework"
231+
}
232+
233+
return withoutDiagnostics + [paths.coreDiagnosticsDir]
234+
}()
235+
236+
// Set the newly required framework paths for Analytics.
237+
frameworks["FirebaseAnalytics"] = overriddenAnalytics
238+
}
218239

219240
// TODO: The folder heirarchy should change in Firebase 6.
220241
// Time to assemble the folder structure of the Zip file. In order to get the frameworks

0 commit comments

Comments
 (0)