Skip to content

Commit 7959a0b

Browse files
committed
Fixed rare compiler error when building using build pipelines
1 parent 7b61824 commit 7959a0b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Sources/TimecodeKit/Utilities/URL.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@ import Foundation
88

99
extension URL {
1010
init(temporaryFileWithData data: Data) throws {
11-
let url = FileManager.default.temporaryDirectory
11+
let url = FileManager.default.temporaryDirectoryCompat
1212
.appendingPathComponent(UUID().uuidString)
1313
try data.write(to: url)
1414
self = url
1515
}
1616
}
17+
18+
extension FileManager {
19+
/// Backwards compatible method for retrieving a temporary folder from the system.
20+
@_disfavoredOverload
21+
var temporaryDirectoryCompat: URL {
22+
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
23+
return temporaryDirectory
24+
} else {
25+
return URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)