Bundle name?

Mac OSX specific forum
Rinzwind
Enthusiast
Enthusiast
Posts: 697
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Bundle name?

Post by Rinzwind »

When running or debugging it names the file always PureBasic.0.app or similar with no option to specify your own name. Only with Create executable you can set the name. Which is subsequently ignored when debugging again. Can this be changed?
User avatar
Piero
Addict
Addict
Posts: 993
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Debug Created Bundle

Post by Piero »

Code: Select all

-- Save this AppleScript as an app; do not use "purebasic." (with a dot) in your PB app name
-- Drag it into a folder containing your PB app and the PB debugger temp app (…and your source…) 
-- There must be NO other apps! (set PB prefs to "create temporary exe in source folder")
-- Run it and Debug! (It will ask for permissions; be sure to grant!)
-- NOTE: You can use it to create the executable only once, and then always use compile/run, with or without Debugger…
property deb : "/Applications/PureBasic.app/Contents/Resources/compilers/pbdebugger.app/Contents/MacOS/pbdebugger " -- space on end
property pb : "purebasic." -- PB temp contains (begins with) this
try
	tell application "Finder"
		set dir to container of (path to me)
		set nf to name of (path to me)
		set myapp to 1st item of dir whose name ends with ".app" and name is not nf and name does not contain pb
		set pbapp to 1st item of dir whose name ends with ".app" and name is not nf and name contains pb
		set nmyapp to characters 1 thru -5 of (name of myapp as text) as text
		set npbapp to characters 1 thru -5 of (name of pbapp as text) as text
		set pbapp to POSIX path of (pbapp as text) & "/Contents/MacOS/" & npbapp
		set myapp to POSIX path of (myapp as text) & "/Contents/MacOS/" & nmyapp
		set cp to "cp -f " & quoted form of pbapp & " " & quoted form of myapp
		display dialog "Copy —> Replace:" & linefeed & linefeed & pbapp & "\n\n" & myapp with title "Replace " & nmyapp & "?" -- cancel?
		do shell script cp -- copy/replace executable
		display dialog "Debug?" with title "Standalone Debugger"
		do shell script deb & quoted form of myapp -- open with debugger
	end tell
on error e number n
	if n is -128 then return -- cancelled
	display dialog e buttons "OK" default button 1
end try
Edit: Added a bit more info and made some "code cleanup"
Last edited by Piero on Sun Sep 21, 2025 12:35 pm, edited 1 time in total.
wombats
Enthusiast
Enthusiast
Posts: 720
Joined: Thu Dec 29, 2011 5:03 pm

Re: Bundle name?

Post by wombats »

Are you using Projects? You can setup different targets and specify a filename for the output executable, then build them at the bottom of the "Compiler" menu.
User avatar
Piero
Addict
Addict
Posts: 993
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Bundle name?

Post by Piero »

wombats wrote: Sat Sep 20, 2025 5:38 pm Are you using Projects? You can setup different targets and specify a filename for the output executable, then build them at the bottom of the "Compiler" menu.
Just out of curiosity, do you have a Mac? It seems you dunno Mac apps are packages; you must be very cautious about them not to get overwritten after your careful crafting… :cry: :lol:
wombats
Enthusiast
Enthusiast
Posts: 720
Joined: Thu Dec 29, 2011 5:03 pm

Re: Bundle name?

Post by wombats »

I do, yes. I like to create a program to be launched after build to handle adding things to the app bundle.
User avatar
mk-soft
Always Here
Always Here
Posts: 6270
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Bundle name?

Post by mk-soft »

You can already do this with IDE tools.
I do it this way because I simply copy all the necessary files after compiling and before starting them into the APP.

Link: viewtopic.php?t=61638
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Piero
Addict
Addict
Posts: 993
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Bundle name?

Post by Piero »

Well, this script just replaces the binary into the package, so it leaves the rest of your app bundle untouched, and if you compile/run without debugger, you can also save the "final version"…
Does PB overwrite only (icons) binary and Info.plist on "create executable"? That's what it seems to me until now
User avatar
mk-soft
Always Here
Always Here
Posts: 6270
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Bundle name?

Post by mk-soft »

You can also edit the plist.info yourself with Xcode or with another editor and replace them.

With my tool MyAppData I have integrated a simple plist editing (not quite perfect but sufficient)
Thus, the BundleName in the plist.info is customised.

Code: Select all

;-TOP

; Info.plist
;
; PLIST <key>CFBundleName</key>
; PLIST <string>MyApp</string>
; PLIST <key>CFBundleShortVersionString</key>
; PLIST <string>1.01.1</string>
; PLIST <key>NSHumanReadableCopyright</key>
; PLIST <string>©2025 mk-soft. All rights reserved.</string>

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(0)
  dy = WindowHeight(0) - StatusBarHeight(0) - MenuHeight()
  ; Resize Gadgets
EndProcedure

Procedure Main()
  Protected dx, dy
  
  #WinStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(0, #PB_Ignore, #PB_Ignore, 600, 400, "Test Window", #WinStyle)
    ; MenuBar
    CreateMenu(0, WindowID(0))
    MenuTitle("&File")
    MenuItem(99, "E&xit")
    
    ; StatusBar
    CreateStatusBar(0, WindowID(0))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(0)
    dy = WindowHeight(0) - StatusBarHeight(0) - MenuHeight()
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), 0)
    
    ; Main Loop
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case 0
              Break
          EndSelect
          
        Case #PB_Event_Menu
          Select EventMenu()
            Case 99
              PostEvent(#PB_Event_CloseWindow, 0, 0)
              
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply