Workaround for AppleScript-ObjectiveC outlets bug in Xcode 13+

As I’m sure everyone’s aware, Xcode 13 introduced a severe bug: outlets specified in scripts are not recognized in Interface Builder anymore. It’s still not fixed in Xcode 14.

I have my workaround but I wonder if there are smarter ways to deal with this bug.

Here’s what I’m doing:

Have the app delegate object instantiated in IB (it’s always instantiated in my apps anyway).

In the script, create a usual outlet property:

property appController : missing value

Then in the beginning of the script add the following:

set appController to current application‘s NSApp‘s delegate()

This appController property can now be used as an outlet as usually.

If I need another outlet in the script, I first define it in the delegate header:

@property (nonatomic, retain) IBOutlet NSSomeClass *anotherOutlet;

Then call this property in the script:

 set anotherOutlet to appController‘s anotherOutlet()

Then anotherOutlet can also be used as a regular outlet.

So this method works. But, once again, I wonder if there are better workarounds for this bug?

Thanks,
Leo

Actually Apple just asked me for a sample project that demonstrates the issue.

Pretty fast considering I submitted a new bug report on the issue only a few days ago.

Albeit the first one submitted back in February didn’t get any traction. Maybe prefacing the title with “SEVERE BUG, NOT FIXED” this time helped draw some attention.

I sent them a sample project - hope it will be fixed finally.

Ok after reviewing the sample project I sent, Apple replied with the following (edited for clarity):

Does adding a new outlet property to the AppleScriptObjC script help trigger a prompt to install python 3 and command line tools? If so, does installing the tools help resolve the unrecognized connections? Python3 is currently needed for IB’s AppleScript outlet detection.

I replied that I never saw any kind of prompts regarding Python 3 (or any prompts related to AppleScript outlets in general). Plus I do have Python 3 installed in /usr/bin/python3 (just like anybody else I guess).

I’ll keep you updated on any further developments.

1 Like

Ok it looks like as of at least Xcode 14.0.1 this issue is fixed when running Xcode on Monterey.

The issue is still there on macOS Ventura (latest beta). However, as I discovered just recently, Xcode 14 on Ventura doesn’t recognize ANY outlets at all - including the ones defined in Objective-C classes. So it’s probably an issue not specific to AppleScriptObjC.

And since up until a few days ago I only ran Xcode 14 on Ventura, it’s quite possible that this bug was indeed fixed from the start when running Xcode 14 on a stable macOS release.

Definitely should have tried Xcode 14 on Monterey too before claiming this bug wasn’t fixed - but I was just too confident that this issue wouldn’t be affected by the operating system itself. Looks like I was wrong :confused: