Fix Apple simulator and Swift 6 build plumbing
This commit is contained in:
parent
cdf8d22055
commit
f9062eae33
7 changed files with 188 additions and 50 deletions
|
|
@ -1,4 +1,5 @@
|
|||
@_implementationOnly import CConstants
|
||||
import Foundation
|
||||
import OSLog
|
||||
|
||||
public enum Constants {
|
||||
|
|
@ -27,9 +28,30 @@ public enum Constants {
|
|||
private static let _groupContainerURL: Result<URL, Error> = {
|
||||
switch FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier) {
|
||||
case .some(let url): .success(url)
|
||||
case .none: .failure(.invalidAppGroupIdentifier)
|
||||
case .none:
|
||||
fallbackContainerURL().mapError { _ in .invalidAppGroupIdentifier }
|
||||
}
|
||||
}()
|
||||
|
||||
private static func fallbackContainerURL() -> Result<URL, any Swift.Error> {
|
||||
#if targetEnvironment(simulator)
|
||||
Result {
|
||||
let baseURL = try FileManager.default.url(
|
||||
for: .applicationSupportDirectory,
|
||||
in: .userDomainMask,
|
||||
appropriateFor: nil,
|
||||
create: true
|
||||
)
|
||||
let url = baseURL
|
||||
.appending(component: bundleIdentifier, directoryHint: .isDirectory)
|
||||
.appending(component: "SimulatorFallback", directoryHint: .isDirectory)
|
||||
try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
|
||||
return url
|
||||
}
|
||||
#else
|
||||
.failure(Error.invalidAppGroupIdentifier)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
extension Logger {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue