JXA-Cookbook
JXA-Cookbook copied to clipboard
NSInvalidArgumentException: NSGetSizeAndAlignment(): unsupported type encoding spec 'G' at 'GPoint}"size"{CGSize}}' in '{CGPoint}"size"{CGSize}}'
I'm trying to create a quick action that will resize images based on pixel sizes I enter. The code I'm using at some point needs a CGRect, but whenever I create one, Automator exits immediately. A minimal example is:
ObjC.import('Cocoa')
function run(input, parameters) {
const rect = $.CGRectMake(0, 0, 200, 200);
return input;
}
When I run this, Automator exits. Any idea why? I get the same thing with NSMakeRect. In my actual usage I have debugger before and after, so I know it's on this statement. I'm getting the following in the crash report:
Application Specific Information:
dyld3 mode
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSGetSizeAndAlignment(): unsupported type encoding spec 'G' at 'GPoint}"size"{CGSize}}' in '{CGPoint}"size"{CGSize}}''
terminating with uncaught exception of type NSException
abort() called
Since this looks like a bug, I've submitted feedback to Apple.
Great resource by the way, much better than anything Apple has provided, despite being a bit old now.
If you can, update to Big Sur and see if it is fixed there.
Unfortunately it's my only laptop, and we're under stage 4 restrictions, so I'm currently pretty dependent on it. I'm reaching out to others I know to see if they can.
This is an ongoing issue so I will keep this open. I don't know what is going to happen when Big Sur is finally released.
Still occurring on macOS 10.15.7. So lame. 😒
Still occurring on Big Sur.
#44
This works now on Monterey.