   ///   - platform: The platform to target for the build.
   ///   - buildDir: Location where the project should be built.
   ///   - logRoot: Root directory where all logs should be written.
+  ///   - setCarthage: Set Carthage flag in CoreDiagnostics for metrics.
   /// - Returns: A URL to the framework that was built.
   private func buildSlicedFramework(withName framework: String,
                                     platform: TargetPlatform,
                                     buildDir: URL,
-                                    logRoot: URL) -> URL {
+                                    logRoot: URL,
+                                    setCarthage: Bool = false) -> URL {
     let isMacCatalyst = platform == .catalyst
     let isMacCatalystString = isMacCatalyst ? "YES" : "NO"
     let workspacePath = projectDir.appendingPathComponent("FrameworkMaker.xcworkspace").path
-    let distributionFlag = includeCarthage ? "-DFIREBASE_BUILD_CARTHAGE" :
+    let distributionFlag = setCarthage ? "-DFIREBASE_BUILD_CARTHAGE" :
       "-DFIREBASE_BUILD_ZIP_FILE"
     let cFlags = "OTHER_CFLAGS=$(value) \(distributionFlag)"
     let archs = platform.archs.map { $0.rawValue }.joined(separator: " ")

      let sliced = buildSlicedFramework(withName: framework,
                                        platform: platform,
                                        buildDir: buildDir,
                                        logRoot: logsDir)
      slicedFrameworks[platform] = sliced
    }
    return slicedFrameworks

      if framework == "FirebaseCoreDiagnostics" {
        // FirebaseCoreDiagnostics needs to be built with a different ifdef for the Carthage distro.
        carthageThinArchives = buildFrameworksForAllPlatforms(withName: framework,
                                                              logsDir: logsDir,
                                                              setCarthage: true)
      } else {
        carthageThinArchives = slicedFrameworks
      }
