I can’t say I know a lot about ASOC and even less about ObjectiveC “ I’m just learning a lot. But what’s happening now in my project is definitely a mystery to me.
The application is controlled by a menulet, with menu items triggering an assortment of handlers that open different (combinations of) other applications and folders. Eventually I want to make it completely configurable, so far I just point each of the menu items to a handler in the AppDelegate.applescript. Like:
on startPhotoShop_(sender)
tell application "Photoshop" to activate
end startPhotoShop_
Easy enough and it works fine. When I choose the Photoshop item in the menu, Photoshop runs as it should. Like all the other things in similar other handlers do.
But.
Whenever I run Xcode and open the project and run it, Photoshop launches out of the blue. Just like that, without me even touching the menu or anything else.
Well, I tried everything I can think of.
It only happens the first time I run the project after launching Xcode.
It doesn’t happen when I close the project keeping Xcode running and open and run the project again.
It doesn’t happen on any subsequent run within Xcode.
It doesn’t happen when I build and run the resulting .app file outside Xcode.
It doesn’t happen with any of the other applications and folders that are launched in other handlers.
It doesn’t happen when I comment out the startPhotoShop handler, or even just the ‘tell application…’ line.
It doesn’t happen when I change ‘Photoshop’ to ‘Photoshap’ or anything else.
So I wondered if the ghost hides inside or outside the handler. So I tried:
on startPhotoShop_(sender)
display dialog "Photoshop about to start"
tell application "Photoshop" to activate
end startPhotoShop_
When I choose the Photoshop menu item, the dialog dutifully appears before Photoshop runs.
But on that fateful first run in Xcode, again Photoshop comes up - be it without that dialog appearing!
Beats me, like nothing else I experienced in Xcode so far. Of course this is no show stopper and I really should continue learning how to do useful things, but it keeps me all but awake…
Model: iMac
AppleScript: Xcode 4.5
Browser: Safari 536.25
Operating System: Mac OS X (10.8)