func run()

in Sources/XCRemoteCache/Commands/Plugins/Thinning/ThinningConsumerPostbuildPlugin.swift [118:149]


    func run(meta: MainArtifactMeta) throws {
        onRun()
        // iterate all thinned targetName temp dirs and perform postbuild action
        let allCachedTargetFileKeys = ThinningPlugin.extractAllProductArtifacts(meta: meta)
        let thinnedTargetFileKeys = allCachedTargetFileKeys.filter { targetName, _ in
            thinnedTargets.contains(targetName)
        }
        // Ensure all thinned targets keys are available in a meta
        // (This is a second safety-net for. The same validation is done in the prebuild phase)
        let missedThinnedTargets = Set(thinnedTargets).subtracting(Set(thinnedTargetFileKeys.keys))
        guard missedThinnedTargets.isEmpty else {
            let targetNames = Array(missedThinnedTargets)
            let rawError = ThinningConsumerPostbuildPluginError.missingArtifactKey(targetNames: targetNames)
            // Thin project requires all artifacts to be available locally - has to fail immediately
            throw PluginError.unrecoverableError(rawError)
        }
        let archs = try swiftProductsArchitecturesRecognizer.recognizeArchitectures(
            builtProductsDir: builtProductsDir,
            moduleName: productModuleName
        )

        for (targetName, fileKey) in thinnedTargetFileKeys {
            worker.appendAction {
                try self.performPostbuildFor(targetName: targetName, productArchs: archs, fileKey: fileKey)
            }
        }
        if case .errors(let errors) = worker.waitForResult() {
            let rawError = ThinningConsumerPostbuildPluginError.failed(underlyingErrors: errors)
            // Thin project requires all artifacts to be available locally - has to fail immediately
            throw PluginError.unrecoverableError(rawError)
        }
    }