Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

790 B
Raw Blame
import Foundation

package enum XToolCache {
    package static var directory: URL {
        let env = ProcessInfo.processInfo.environment
        if let tmpdir = env["XTL_TMPDIR"], !tmpdir.isEmpty {
            return URL(fileURLWithPath: tmpdir).appendingPathComponent("sh.xtool")
        }
        #if os(Linux)
        let xdgCache: URL
        if let xdgCachePath = env["XDG_CACHE_HOME"],
           (xdgCachePath as NSString).isAbsolutePath {
            xdgCache = URL(filePath: xdgCachePath)
        } else {
            xdgCache = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent(".cache")
        }
        return xdgCache.appending(component: "xtool")
        #else
        return URL.cachesDirectory.appending(component: "sh.xtool")
        #endif
    }
}