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