in Sources/XCRemoteCache/Commands/Libtool/XCCreateUniversalBinary.swift [60:96]
func run() {
// check if RC is enabled. if so, take any input .a and copy to the output location
let fileManager = FileManager.default
let config: XCRemoteCacheConfig
do {
let srcRoot: URL = URL(fileURLWithPath: fileManager.currentDirectoryPath)
config = try XCRemoteCacheConfigReader(srcRootPath: srcRoot.path, fileReader: fileManager)
.readConfiguration()
} catch {
errorLog("\(toolName) initialization failed with error: \(error). Fallbacking to \(fallbackCommand)")
fallbackToDefault()
}
let markerURL = tempDir.appendingPathComponent(config.modeMarkerPath)
do {
let markerReader = FileMarkerReader(markerURL, fileManager: fileManager)
guard markerReader.canRead() else {
fallbackToDefault()
}
// Remote cache artifact stores a final library from DerivedData/Products location
// (an universal binary here)
// Fot a target where universal binary is used as a product, an output from single-architecture `xclibtool`
// already is a universal library (the one from artifact package)
// Link any of input libraries (here first) to the final output location because xclibtool flow ensures
// that these are already an universal binary
try fileManager.spt_forceLinkItem(at: firstInputURL, to: output)
} catch {
errorLog("\(toolName) failed with error: \(error). Fallbacking to \(fallbackCommand)")
do {
try fileManager.removeItem(at: markerURL)
fallbackToDefault()
} catch {
exit(1, "FATAL: \(fallbackCommand) failed with error: \(error)")
}
}
}