Got it running well from Xcode. Now I can look at the intricacies of the project. It looks interesting.
Can you post something if you get it running outside of Xcode?
Thanks a lot,
kel
Got it running well from Xcode. Now I can look at the intricacies of the project. It looks interesting.
Can you post something if you get it running outside of Xcode?
Thanks a lot,
kel
It does already – just Project → Build For → Profiling or Archiving. Then find the executable and double-click.
Now I can look at the intricacies of the project. It looks interesting.
Um, belated welcome to AppleScriptObjC. There’s a forum nextdoor
Oh, and you might want to comment out the line:
close project document "SystemMenu.xcodeproj"
I suspect that’s what’s causing MacUsr’s problems.
Thank you a whole lot Shane!
Thanks for the welcome Shane.
McUsr, nice template. It looks easy to change the menu items. Still can’t get it to run outside Xcode, but now that I know it can be done, I’ll keep trying. I tried build for Profiling and Archiving. Both didn’t work. Just thought of this that I might have to move the app out of the debug folder.
Thanks a lot,
kel
Hello.
I put the first block that Shane said didin’t work into a try-end try block, so that it works as it should from within XCode, and is neglected outside. Then I chose “Build and Archieve” from my XCode 3.2 menu, and chose “Reveal in Finder” from the window pane you see when the top level object in XCode’s left pane is selected. And I started it from Finder, and it works as it should!
Thanks a whole lot Shane, it isn’t that easy, when you don’t know your way around with it, I guess I could read up on this somewhere.
I’ll just have to find something to apply it on.
This litle project, must be the biggest cherry of AsObjC, anybody can feel free to use it for whatever the purpose, as long as I am not to be held responsible for any kind of trouble. Nor DJ Bazzie Wazzie, it is his code that does the workings by the way, without that code it wouldn’t be much of a project!
P.S
As a side note, during this endeavour, I discovered a utility that is named CpMac in the Developer tools selection. It should be able to copy apps, and other Mac stuff pretty reliable, retaining, what is there to retain.
Or look in Console for errors…
It would look more like it if you’d written it outside Xcode. There’s really no need to use Xcode for ASObjC projects that don’t use more complex UIs – it just makes it more likely that Xcode issues are going to cause problems because of its complexity, as here.
But FWIW, ASObjC is full of cherries…
CpMac was the original developer option when cp ignored file metadata. But it’s a bit long in the tooth now; I suspect it would be safer to stick to cp.
Hello.
I discovered it in the Console as well, at the same time I read your post.
I am going to use it to control the workflow of XCode with, at least for a while, so for me, it is ideal to have it from within XCode. I guess it should be easy for anybody to move it to ASObjC Explorer, or maybe even the AppleScript Editor, without much ado. And they are welcome to do that, and to share the result!
It is interesting to hear about the CpMac, and assuring to know that cp would work as expected, but I’d have to use cp -r to copy a whole application wouldn’t I? -I’ll have to try that out, see if cp copies a whole application indeed.
Hi McUsr,
When I create a new Cocoa-AppleScript app, and past in DJ Bazzie Wazzies script it works fine in and out of Xcode. Here’s the script:
script AppDelegate
property parent : class "NSObject"
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
--create a menu item
set myMenuItem to current application's class "NSMenuItem"'s alloc()'s init()
tell myMenuItem to setTitle_("Hello World")
tell myMenuItem to setTarget_(me)
tell myMenuItem to setAction_("helloWorld:")
--create a menu
set myMenu to current application's class "NSMenu"'s alloc()'s init()
tell myMenu to addItem_(myMenuItem)
set myBar to current application's class "NSStatusBar"'s systemStatusBar()
--add the menu to the system's status bar
set theItem to myBar's statusItemWithLength_(current application's NSVariableStatusItemLength)
tell theItem to setTitle_("MyMenu")
tell theItem to setHighlightMode_(true)
tell theItem to setMenu_(myMenu)
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
--actions
on helloWorld_(info)
display dialog "Hello World!"
end helloWorld_
end script
Trying to figure out what’s the difference between your app and this brand new one.
gl,
kel
Think I found it. Your downloaded SystemMenu.app had Architectures set to 32/64-bit. I changed it to just 64-bit and now it works in and out of Xcode.
gl,
kel
Hello kel.
I am sorry for all the trouble, I’ll change it to 64-bit only, I guess it will only run from Snow Leopard onwards anyway,
I hope really you find this useful after all your trouble, and by the way, if you “Build and Archieve” (from XCode’s Build menu), then it should run from outside XCode as well.
I have updated the zip-file that you can get at in post number 66.
Hi McUsr,
It was a great learning experience!
gl,
kel
Hello kel.
I am really glad you see it that way, and I hope you find the extra menu useful as well.
It is to me, since it is so easy to change on the fly. If you saw the link that Stefan posted in the other thread, now that is the basis for a more professional version. But all I need for the time being is something quick and dirty, and DJ Bazzie Wazzies code is just the right basis.
It was, I have a treat for you!
An applet over at code exchange, that you install as a toolbar, and then you just drop scripts into it, next time you click on the toolbar button in Finder, its added to the list over scripts to execute. (on the selection for instance.)
Only caveat I can’t seem to bypass is that for some reason I have to click twice after I add a script.
What version of Xcode/OS?
MacUsr,
You still haven’t explained why you’d ever need to launch it from Xcode. It seems to me you’re just adding un unnecessary level of complexity.
I don’t need. It is just that I use the menu for tailoring workflows with XCode, so, when XCode is open, for starters, I like the project to launch there for editing, and when I am done, I build it, up comes the new menu, and the project closes. I uses XCode for everything that involves Mac Frameworks now, even with its lousy code completion compared to the one I have in vim (on the fly compilation/syntax checking too), since the Object-browser, online documentation, and GDB integration far outweighs anything else.
I guess the why in XCode, has something to do with laziness, I can continue where I left off before editing the menu, hopefully testing what I just implemented.
Hi Shane,
Xcode: Version 4.6.2 (4H1003). I updated today to os10.8.4 and some other stuff, so not sure what I had. Is your’s the same version?
Edited: come to think of it, I had a problem when downloading your program. I had to do something with the 32-bit 64-bit thing otherwise it wouldn’t compile after the first run. Maybe something in my computer is set up wrong somehow.
gl,
kel
Yep. I did fiddle with the build settings though, and I can’t remember how. I suppose I should download it again…
It may well be something lost or unnecessary from/between Xcode 3.x and 4.x.