diff --git a/Sources/XToolSupport/DevCommand.swift b/Sources/XToolSupport/DevCommand.swift index b699ebda..83f8ac65 100644 --- a/Sources/XToolSupport/DevCommand.swift +++ b/Sources/XToolSupport/DevCommand.swift @@ -137,12 +137,8 @@ struct DevBuildCommand: AsyncParsableCommand { if ipa { @Dependency(\.zipCompressor) var compressor finalURL = url.deletingPathExtension().appendingPathExtension("ipa") - let tmpDir = try TemporaryDirectory(name: "sh.xtool.tmp") - let payloadDir = tmpDir.url.appendingPathComponent("Payload", isDirectory: true) - try FileManager.default.createDirectory( - at: payloadDir, - withIntermediateDirectories: true - ) + let tmpDir = try TemporaryDirectory(name: "Payload") + let payloadDir = tmpDir.url try FileManager.default.moveItem(at: url, to: payloadDir.appendingPathComponent(url.lastPathComponent)) let ipaURL = try await compressor.compress(directory: payloadDir) { progress in if let progress { diff --git a/Sources/XUtils/TemporaryDirectory.swift b/Sources/XUtils/TemporaryDirectory.swift index 9873124e..6f50a303 100644 --- a/Sources/XUtils/TemporaryDirectory.swift +++ b/Sources/XUtils/TemporaryDirectory.swift @@ -13,6 +13,10 @@ package struct TemporaryDirectory: ~Copyable { _ = TemporaryDirectoryRoot.shared } + /// Creates a temporary directory where `lastPathComponent` is exactly `name`. + /// + /// The directory is deleted on deinit or (if the object never deinits) on next launch. + /// To save the contents, move them elsewhere with ``persist(at:)``. package init(name: String) throws { do { let basename = name.replacingOccurrences(of: ".", with: "_")