[Solved] Objective-C Scripting broke with 3.9.1

Hey,

with quite some unease I noticed that scripting with Objective-C doesn’t seem to work anymore since the last update.

I am comparing the current and previous scripting definitions (sdef), but cannot find evidence of any breaking changes that would explain why there is a problem. To give a few examples: I am using ScriptingBridge to automate DNTp with Swift, and while it worked as expected in version 3.9 to access, say, the databases, version or name of the DEVONthink3Application class, now it fails.

guard let app: DEVONthink3Application = SBApplication(bundleIdentifier: bundleIdentifier) else {
	return nil
}

While some methods still seem to work, most of them do not:

(lldb) po app.version
▿ Optional<String>
  - some : "" # should be "3.9.1
(lldb) po app.name
▿ Optional<String>
  - some : "" 
(lldb) po app.databases?()
▿ Optional<SBElementArray>
  - some : 0 elements
(lldb) po app.getDatabaseWithId?(2)
nil

Some objects are still found:

(lldb) po app.currentDatabase
▿ Optional<DEVONthink3Database>
  - some : <SBObject @0x600000cc9c80: currentDatabase of application "DEVONthink 3" (1144)>
(lldb) po app.inbox
▿ Optional<DEVONthink3Database>
  - some : <SBObject @0x600000cbc8d0: inbox of application "DEVONthink 3" (1144)>
(lldb) po app.activate() # also works

When drilling deeper, however, the method calls fail again:

(lldb) po app.currentDatabase?.name
▿ Optional<String>
  - some : ""
(lldb) po (app.currentDatabase! as DEVONthink3Database).name
▿ Optional<String>
  - some : ""
(lldb) po app.inbox!.name
▿ Optional<String>
  - some : ""

The AppleScript equivalents work fine.
Why is this happening? :sob:

Development can comment further if they choose to but there is no specific support in DEVONthink for what you are doing.

False Alarm! The debugger led me down the wrong path, when the problem I was experiencing was actually with something else… Sorry about that! All is well.

1 Like

Glad to hear it :slight_smile: