Xcode 16 doesn't show log entries from AppleScriptObjC scripts in Xcode console

Just a heads up for those who use AppleScriptObjC scripts in Xcode projects:

Xcode 16 currently doesn’t show log entries from AppleScriptObjC scripts in Xcode console.

For example, neither of these will produce any output in Xcode:

log "something"
current application's NSLog("something")

As a workaround, I’m temporarily calling a method that’s calling NSLog in an Objective-C class.

(ASOC logs appear as normally in Console.app).

I’m sure those who are affected will also submit this bug soon.

1 Like

I’ve just received the following reply from Apple regarding this bug:

Engineering has provided the following information regarding this issue:

This has ever worked, at least not the way you’re doing it. (Also, terminology: AppleScriptObjC refers to the AppleScript/Objective-C bridge — using Objective-C frameworks from AppleScript. This is merely using NSAppleScript to execute a script.)

AppleScript’s “log” statement relies on having an Apple event handler for it installed in the current process. Script Editor and osascript provide this, but NSAppleScript does not. You would either have to run your script via osascript, probably using NSTask, or else install your own event handler for kASAppleScriptSuite/kASComment in your process.

Frankly, I have very little idea of what they’re talking about. All I know is that the log command did work in Xcode logs prior to Xcode 16.

My current workaround for this is to create a custom method that calls NSLog in the Objective-C app delegate, which method I call from ASOC. (It’s quite possible that better workarounds exist.)

I wrote a small NSObject logging script and ObjC code.
This code may help you to log various information. This is the first step and small project.

http://piyocast.com/as/archives/17133

Thanks I’ll take a look. In the meantime, my primitive workaround does what I need.

It would be nice if Apple didn’t break simple things that worked since like forever :\