Page 1 of 1

Bundle name?

Posted: Wed Sep 17, 2025 12:16 pm
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?

Debug Created Bundle

Posted: Fri Sep 19, 2025 5:41 pm
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"

Re: Bundle name?

Posted: Sat Sep 20, 2025 5:38 pm
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.

Re: Bundle name?

Posted: Sat Sep 20, 2025 6:05 pm
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:

Re: Bundle name?

Posted: Sat Sep 20, 2025 8:20 pm
by wombats
I do, yes. I like to create a program to be launched after build to handle adding things to the app bundle.

Re: Bundle name?

Posted: Sat Sep 20, 2025 11:35 pm
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

Re: Bundle name?

Posted: Sun Sep 21, 2025 9:16 am
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

Re: Bundle name?

Posted: Sun Sep 21, 2025 10:27 am
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()