• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Cocoa scripting: targeting an app via its bundle identifier
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa scripting: targeting an app via its bundle identifier


  • Subject: Cocoa scripting: targeting an app via its bundle identifier
  • From: Andy Lee <email@hidden>
  • Date: Sat, 25 Jun 2011 23:52:14 +0000 (GMT)

This has been bedeviling me all day. As an AppleScript novice I suspect -- I *hope* -- I'm missing something trivial.

I have a scriptable app I want to write AppleScript that targets the app via its bundle identifier rather than its name. But when I do what seems the obvious thing, I get a -1708 error, which I believe means the app doesn't understand the command I'm giving it.

I wrote a trivially scriptable app to isolate and illustrate the problem. Here's my simple script, copied and pasted exactly from AppleScript Editor:

get application id "com.yourcompany.TrivialScriptable"
set myApp to result
tell myApp
	activate
	greet("hello!!!")
end tell

If you're seeing the above as rich text, notice how "greet" is not bold and blue, indicating that the AppleScript compiler indeed thinks my app does not implement the "greet" command.

I'm pretty sure I've set up the app correctly, because targeting it via the app name works:

tell application "TrivialScriptable"
	activate
	greet ("this works")
end tell

In this case the "greet" is properly highlighted.

What am I missing here? Is this some quirk of AppleScript?

Note: I want to use the bundle identifier rather than the app name because in the case of my real app I have an iOS app with the same name. This means there is an XXX.app sitting in the build directory of my iOS project. This confuses AppleScript into targeting the wrong XXX.app.

If you want to see this for yourself, a 26K zip file containing the code for TrivialScriptable is in my public iDisk (user aglee). Build the app and try running the above AppleScript snippets in AppleScript Editor.

If I can't solve this I may change my approach and define a custom URL scheme and use that rather than AppleScript for the inter-app communication I need.

--Andy

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa scripting: targeting an app via its bundle identifier
      • From: Bill Cheeseman <email@hidden>
    • Re: Cocoa scripting: targeting an app via its bundle identifier
      • From: Jeff Johnson <email@hidden>
    • Re: Cocoa scripting: targeting an app via its bundle identifier
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: audiounit instrument with cocoa view
  • Next by Date: Re: Cocoa scripting: targeting an app via its bundle identifier
  • Previous by thread: Re: Event Objects Return 1-Based Y Coordinate Values
  • Next by thread: Re: Cocoa scripting: targeting an app via its bundle identifier
  • Index(es):
    • Date
    • Thread