SwiftUI: как узнать путь к базе Core Data.
Путь разный для приложений на macOS и iOS.
Функция:
func pathSQLite() {
let path = FileManager
.default
.urls(for: .applicationSupportDirectory, in: .userDomainMask)
.last?
.absoluteString
.replacingOccurrences(of: "file://", with: "")
.removingPercentEncoding
print(path ?? "Not found")
}
Кнопка для запуска:
Button(action:{withAnimation {pathSQLite()}}){Text("путь к базе")}
Необходимо зайти в Finder, нажать Command -Shift-G и ввести полученный ранее путь.
