Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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

Reply
1 reply

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.

How to add applescript to xcode objc

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.