use framework “…” fails. The error display in Script Debugger is:
"+[CocoaFromApplescript hello]: unrecognized selector sent to class 0x1124f3150"
As a proof of concept, I have successfully made use of the FScript.framework from AppleScript as follows:
use framework “FScript”
set myBool to current application’s FSBoolean’s fsTrue
Script Debugger shows the value of myBool as:
Trying to mirror the successful use of FScript.framework, I have used Xcode to build the framework:
with a few methods:
CGPoint mouseMove(CGFloat x, CGFloat y, bool click);
+ (void) EXAMPLEmouseMove;
The build framework is installed in /Library/Frameworks and successfully tested with calls from an Xcode project:
- (IBAction) Button1:sender
[sender setEnabled:FALSE]; // disable subsequent click until the return from the action call
mouseMove(50, 80, false);
But the attempt to test the MyCocoa methods from AppleScript fail (using the same syntax that works for FScript):
use framework " CocoaFromApplescript"
current application’s CocoaFromApplescript’s hello() – “+[CocoaFromApplescript hello]: unrecognized selector sent to class 0x1124f3150”
current application’s CocoaFromApplescript’s EXAMPLEmouseMove – “Can’t get MyCocoa of CocoaFromApplescript.”
Inspecting my framework, CocoaFromApplescript (using the terminal command ‘nm’), it appears to have accessible methods just like the FScript framework. And as noted above, my CocoaFromApplescript.framework behaves as expected when its routines are called from my test application:
In lieu of getting this framework strategy to work, maybe there is a simpler way to be able to call a custom class method from an AppleScript routine that was called from an objc app?
Hopefully someone has grappled successfully with this and can point me in the right direction.
Thanks in advance.