Is there a GRDB for macOS

Is there something like GRDB for macOS development?

Thanks

Looking at the GRDB documentation, it seems like it supports MacOS 10.10, 10.11, 10.12, ..., 10.15. I would assume it will be ported over to MacOS 11. There is a GRDBOSX target in the Xcode project/workspace

I see what you are saying. It does look like it supports macOS.
The following screen shot is what confused me. As you can see the platform mentioned don't include macOS. Although below low that in requirements it does have macOS 10.10+.

At any rate since it does appear to support macOS.... is there a demo of GRDB with a macOS target?

osx == macOS, the platform image just hasn't been updated with the new name.

I doubt the API is any different on macOS than iOS, so a demo wouldn't do much. Give sample code a shot and see what happens.

Thanks, I will... Also,I must confess I knew full well that OS X = macOS. I was just had tunnel vision.

So, I am following the following document:

Getting Started with GRDB

In trying to convert the IOS code at the top to OS X code at the bottom I not sure how to code
DataBaseManager class for OS X as well as the code to call the setup method.

Any help with this is appreciated.
Create new file called DataBaseManager.swift

*IOS code
import GRDB
var dbQueue: DatabaseQueue!
class DatabaseManager {
static func setup(for application: UIApplication) throws {
let databaseURL = try FileManager.default
.url(for: .applicationDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent("db.sqlite")
dbQueue = try DatabaseQueue(path: databaseURL.path)
dbQueue.setupMemoryManagement(in: application)
Call the setup method in your AppDelegate

}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
try! DatabaseManager.setup(for: application)
return true
}

OSX/macOS
import Cocoa
import GRDB

var dbQueue: DatabaseQueue!

class DatabaseManager {
static func setup(for application: NSApplication) throws {

    let homeURL = FileManager.default.homeDirectoryForCurrentUser
    let desktopPath = "Desktop/"
    let databaseName = "Test.db3"
    let databaseURL = homeURL.appendingPathComponent(desktopPath + databaseName)
    
    print("Path: " + databaseURL.path)

 dbQueue = try DatabaseQueue(path: databaseURL.path)

// dbQueue.setupMemoryManagement(in: application)

}

}

class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(_ aNotification: Notification) {
    // Insert code here to initialize your application
    
 try! DatabaseManager.setup(for: application)
}

In your call to the setup call, use NSApp for the application. NSApp is the shared variable that refers to your main application object. Best to read the about NSApplication, NSApp, in the Apple documentation

I made the change and read the Apple Documentation. I now get the following error:

2020-07-13 14:35:50.945023-0500 PayMe[2382:98653] [logging-persist] os_unix.c:44152: (0) open(/Users/bsoule/Desktop/TestGRDB.db3) - Undefined error: 0

Fatal error: 'try!' expression unexpectedly raised an error: SQLite error 14: unable to open database file: file /Users/bsoule/Documents/Xcode/PayMe/PayMe/AppDelegate.swift, line 21

2020-07-13 14:36:15.392148-0500 PayMe[2382:98653] Fatal error: 'try!' expression unexpectedly raised an error: SQLite error 14: unable to open database file: fil

I have stepped through my program using debug/step into and can't see exactly where it is getting this error. Looking on the web it seems to be a general purpose error. Any ideas how to debug this error?

Also, get the following while running GRDBOSX tour playground?

warning: Tour.playground:130:9: warning: initialization of immutable value 'favoritePlaces' was never used; consider replacing with assignment to '_' or removing it
let favoritePlaces = try Place // [Place]
^~~~~~~~~~
_

Thanks

You likely need to enable disk access in the "Signing & Capabilities" tab of your app target in Xcode.

I still get the same error. I changed the following under sandbox group, it had read before:

Is this where you were referring to?

Sorry, I'm not sure. I suggest the Apple Developer Forums or StackOverflow for general questions like that.

Thanks, I try over there. I will post back when I get it resolved..

I opened a new thread for this issue.

New Thread

Terms of Service

Privacy Policy

Cookie Policy