TikaSoftware

Q: How to add applescript to xcode objc

Hello,

 

So I copied a applescriptobjc file from anther xcode project chosen from the menu. I pasted it next to the .h and .m file, but nothing of this applescript code works. Can somebody make a video on how to do it or tell me detailed and understandable how to do it?

 

Thanks

iMac, OS X Mavericks (10.9.5), It's the beta version of yosemite

Posted on Feb 10, 2015 10:08 AM

Close

Q: How to add applescript to xcode objc

  • All replies
  • Helpful answers

  • by red_menace,

    red_menace red_menace Feb 11, 2015 7:02 PM in response to TikaSoftware
    Level 6 (15,541 points)
    Desktops
    Feb 11, 2015 7:02 PM in response to TikaSoftware

    Well, just throwing random files into an Xcode project isn't really the way to go, regardless of the language.  AppleScriptObjC can be used in an Objective-C project, you just need to set things up to load the files and give Objective-C information about them so that they can be used:

     

    • The AppleScriptObjC framework needs to be added to your project;
    • An informal protocol needs to be set up to declare the handlers/methods in your scripts, since AppleScriptObjC doesn't have any headers;
    • You need to add statements to the main.m file to load the AppleScriptObjC scripts;
    • The script classes need to be instantiated in the Interface Builder or manually in your startup code.

     

    I blew the dust off an older example project of mine that uses a couple of AppleScriptObjC files (they don't do much, mostly logs and a Finder window) from an Objective-C project - it can be downloaded here.