I have a question: I have an app which, when compiled, I duplicate and then rename. For example, /Applications/xojoxapps/myapp.app duplicated to /Applications/xojoxapps/yourapp.app.
However, when I run yourapp, everything from the menubar to CMD-TAB shows the name myapp.
Which means that when I run both myapp and yourapp, I see myapp running twice.
Is there a way to set the app’s menubar- and application name, on app-start, to the file name, so that when you CMD-TAB, one sees myapp and yourapp?
Why not simply name the app correctly from the start instead of renaming the bundle after compile ? You do that in the Build settings inspector for Mac OS X.
At any rate, the app internally could not care less about the name of the bundle file.
@Axel Schneider
That’s okay and can stay that way. I just want to change it while it is running, so OS X shows the user its bundle-name.
@Michel Bujardet
‘Simply name correctly from the start’ assumes I make a mistake and certainly doesn’t answer my question.
The app has its correct name when compiled. Its purpose is to be duplicated x times.
I’ve checked on Windows and there the app shows its new name, when running. So ‘could not care less’ is probably only valid for Mac OS X.
Let’s start with the name of the application in the menu-bar … is that changeable at runtime?
Declare Function NSClassFromString Lib "Cocoa" (className As CFStringRef) As Ptr
Declare Function sharedApplication Lib "Cocoa" Selector "sharedApplication" (aNSApplication As Ptr) As Ptr
Declare Function mainMenu Lib "Cocoa" Selector "mainMenu" (aNSApp As Ptr) As Ptr
Declare Function itemAtIndex Lib "Cocoa" Selector "itemAtIndex:" (aNSMenu As Ptr, index As Integer) As Ptr
Declare Function submenu Lib "Cocoa" Selector "submenu" (aNSMenuItem As Ptr) As Ptr
Declare Sub setTitle Lib "Cocoa" Selector "setTitle:" (aNSMenu As Ptr, NewTitle As CFStringRef)
DIM NSApp As Ptr = sharedApplication(NSClassFromString("NSApplication"))
DIM NSAppMainMenu As Ptr = mainMenu(NSApp)
DIM applicationNSMenuItem As Ptr = itemAtIndex(NSAppMainMenu, 0)
DIM applicationNSSubMenu As Ptr = submenu(applicationNSMenuItem)
setTitle applicationNSSubMenu, "hello"
[quote=304457:@Marc Vos]‘Simply name correctly from the start’ assumes I make a mistake and certainly doesn’t answer my question.
The app has its correct name when compiled. Its purpose is to be duplicated x times.
I’ve checked on Windows and there the app shows its new name, when running. So ‘could not care less’ is probably only valid for Mac OS X.[/quote]
Indeed, Mac and Windows do not work the same way. That does not help but it is a fact. Especially when trying to run several instances of the same app… But hey, since I did not answer your question, have fun now.