Skip to content

Commit b6620d2

Browse files
authored
Changing the Zip Builder to support the new open-source FirebaseCoreDiagnostics (#3461)
1 parent 526a1ad commit b6620d2

File tree

5 files changed

+3
-48
lines changed

5 files changed

+3
-48
lines changed

ZipBuilder/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ These arguments assume you're running the command from the `ZipBuilder` director
4040
**Required** arguments:
4141
- `-templateDir $(pwd)/Template`
4242
- This should always be the same.
43-
- `-coreDiagnosticsDir <PATH_TO_FirebaseCoreDiagnostics.framework>`
44-
- Needed to overwrite the existing Core Diagnostics framework.
4543

4644
Optional comon arguments:
4745
- `-updatePodRepo false`
@@ -59,7 +57,6 @@ Putting them all together, here's a common command to build a releaseable Zip fi
5957

6058
```
6159
swift run ZipBuilder -templateDir $(pwd)/Template -updatePodRepo false \
62-
-coreDiagnosticsDir /private/tmp/tmpUqBxKN/FirebaseCoreDiagnostics.framework \
6360
-releasingSDKs <PATH_TO_current.textproto> \
6461
-existingVersions <PATH_TO_all_firebase_ios_sdks.textproto> \
6562
-customSpecRepos sso://cpdc-internal/firebase

ZipBuilder/Sources/ZipBuilder/FrameworkBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ struct FrameworkBuilder {
418418

419419
// Verify Firebase headers include an explicit umbrella header for Firebase.h.
420420
let headersDir = podsDir.appendingPathComponents(["Headers", "Public", framework])
421-
if framework.hasPrefix("Firebase") {
421+
if framework.hasPrefix("Firebase") && framework != "FirebaseCoreDiagnostics" {
422422
let frameworkHeader = headersDir.appendingPathComponent("\(framework).h")
423423
guard fileManager.fileExists(atPath: frameworkHeader.path) else {
424424
fatalError("Missing explicit umbrella header for \(framework).")

ZipBuilder/Sources/ZipBuilder/LaunchArgs.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ struct LaunchArgs {
4141
private enum Key: String, CaseIterable {
4242
case cacheEnabled
4343
case customSpecRepos
44-
case coreDiagnosticsDir
4544
case deleteCache
4645
case existingVersions
4746
case outputDir
@@ -54,8 +53,6 @@ struct LaunchArgs {
5453
switch self {
5554
case .cacheEnabled:
5655
return "A flag to control using the cache for frameworks."
57-
case .coreDiagnosticsDir:
58-
return "The path to the `CoreDiagnostics.framework` file built with the Zip flag enabled."
5956
case .customSpecRepos:
6057
return "A comma separated list of custom CocoaPod Spec repos."
6158
case .deleteCache:
@@ -82,9 +79,6 @@ struct LaunchArgs {
8279
/// verify expected version numbers.
8380
let allSDKsPath: URL?
8481

85-
/// The path to the `CoreDiagnostics.framework` file built with the Zip flag enabled.
86-
let coreDiagnosticsDir: URL
87-
8882
/// A file URL to a textproto with the contents of a `ZipBuilder_Release` object. Used to verify
8983
/// expected version numbers.
9084
let currentReleasePath: URL?
@@ -130,14 +124,6 @@ struct LaunchArgs {
130124

131125
templateDir = URL(fileURLWithPath: templatePath)
132126

133-
// Parse the path to CoreDiagnostics.framework.
134-
guard let diagnosticsPath = defaults.string(forKey: Key.coreDiagnosticsDir.rawValue) else {
135-
LaunchArgs.exitWithUsageAndLog("Missing required key: `\(Key.coreDiagnosticsDir)` for the " +
136-
"path to the CoreDiagnostics framework.")
137-
}
138-
139-
coreDiagnosticsDir = URL(fileURLWithPath: diagnosticsPath)
140-
141127
// Parse the existing versions key.
142128
if let existingVersions = defaults.string(forKey: Key.existingVersions.rawValue) {
143129
let url = URL(fileURLWithPath: existingVersions)

ZipBuilder/Sources/ZipBuilder/ZipBuilder.swift

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ struct ZipBuilder {
6565
struct FilesystemPaths {
6666
// MARK: - Required Paths
6767

68-
/// The path to the CoreDiagnostics.framework directory with the Zip flag enabled.
69-
var coreDiagnosticsDir: URL
70-
7168
/// The path to the directory containing the blank xcodeproj and Info.plist for building source
7269
/// based frameworks.
7370
var templateDir: URL
@@ -87,9 +84,8 @@ struct ZipBuilder {
8784
var logsOutputDir: URL?
8885

8986
/// Default initializer with all required paths.
90-
init(templateDir: URL, coreDiagnosticsDir: URL) {
87+
init(templateDir: URL) {
9188
self.templateDir = templateDir
92-
self.coreDiagnosticsDir = coreDiagnosticsDir
9389
}
9490
}
9591

@@ -209,29 +205,6 @@ struct ZipBuilder {
209205
print("Frameworks for pod: \(framework) were compiled at \(paths)")
210206
}
211207

212-
// Overwrite the `FirebaseCoreDiagnostics.framework` in the `FirebaseAnalytics` folder. This is
213-
// needed because it was compiled specifically with the `ZIP` bit enabled, helping us understand
214-
// the distribution of CocoaPods vs Zip file integrations.
215-
if podsToInstall.contains(.analytics) {
216-
let overriddenAnalytics: [URL] = {
217-
guard let currentFrameworks = frameworks["FirebaseAnalytics"] else {
218-
fatalError("Attempted to replace CoreDiagnostics framework but the FirebaseAnalytics " +
219-
"directory does not exist. Existing directories: \(frameworks.keys)")
220-
}
221-
222-
// Filter out any CoreDiagnostics directories from the frameworks to install. There should
223-
// only be one.
224-
let withoutDiagnostics: [URL] = currentFrameworks.filter { url in
225-
url.lastPathComponent != "FirebaseCoreDiagnostics.framework"
226-
}
227-
228-
return withoutDiagnostics + [paths.coreDiagnosticsDir]
229-
}()
230-
231-
// Set the newly required framework paths for Analytics.
232-
frameworks["FirebaseAnalytics"] = overriddenAnalytics
233-
}
234-
235208
// Time to assemble the folder structure of the Zip file. In order to get the frameworks
236209
// required, we will `pod install` only those subspecs and then fetch the information for all
237210
// the frameworks that were installed, copying the frameworks from our list of compiled

ZipBuilder/Sources/ZipBuilder/main.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ if args.updatePodRepo {
3939
cocoaPodsUpdateMessage = "CocoaPods took \(-buildStart.timeIntervalSinceNow) seconds to update."
4040
}
4141

42-
var paths = ZipBuilder.FilesystemPaths(templateDir: args.templateDir,
43-
coreDiagnosticsDir: args.coreDiagnosticsDir)
42+
var paths = ZipBuilder.FilesystemPaths(templateDir: args.templateDir)
4443
paths.allSDKsPath = args.allSDKsPath
4544
paths.currentReleasePath = args.currentReleasePath
4645
paths.logsOutputDir = args.outputDir?.appendingPathComponent("build_logs")

0 commit comments

Comments
 (0)