Page 1 of 2

Strange behaivour when unpacking my app from a downloaded zip file

Posted: Sun Jan 14, 2024 8:41 pm
by Lebostein
It's strange and I don't know what to do.

I have two identical zip files with an arm64 compiled PB app. The files have the same checksum. One file was the original zip file, the second file was uploaded to my website and then downloaded again. As I said, even after downloading, they have the same checksum.

If I uncompress the files, the app from the original zip can be launched. But the app from the downloaded zip cannot be opened. I see the error message "The app is damaged and can’t be opened. You should move it to the Trash". :?: (macOS 13.6.3)

I have no problem with a x64 app inside the zip.

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Wed Jan 17, 2024 2:51 am
by Piero
Hmmm… I believe some Mad Italian posted some stuff that may help you...
But don't forget google…

https://www.purebasic.fr/english/viewtopic.php?t=81549

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Wed Jan 17, 2024 9:28 am
by jamirokwai
I compiled the steps needed for notarization on MacOS some time ago.
If you like to experience some pain :? check here:

https://www.purebasic.fr/english/viewtopic.php?t=80722

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Wed Jan 17, 2024 7:46 pm
by Lebostein
xattr -cr MyApp.app
Thats it! Thanks. But why? How I offer such App now? This seems to be impossible without a manual terminal command.

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Wed Jan 17, 2024 8:55 pm
by infratec
Build a dmg file.

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Thu Jan 18, 2024 4:29 am
by Lebostein
infratec wrote: Wed Jan 17, 2024 8:55 pm Build a dmg file.
That was also my first thought yesterday. But it doesn't seem to solve the problem.

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Thu Jan 18, 2024 9:01 am
by Fred
You need to notarize it as jamirokwai said.

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Thu Jan 18, 2024 11:01 am
by Piero
Maybe this can help?
Forgive me: I saw a great tool, but didn't bookmark, and have no time now…

https://www.startpage.com/do/dsearch?q= ... ge=english

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Fri Jan 19, 2024 9:55 pm
by Piero
I found this:
https://ohanaware.com/appwrapper/ (14-Day trial, then $49.99, €58.99)

…but I'm almost sure there's also some good free stuff somewhere… grrr...

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Sat Jan 20, 2024 7:20 am
by Piero
I noticed a weird thing: after dropping your "damaged" app into e.g. Terminal ICON (NOT window: I have it on Dock…) it will be OK to run!

Also, take a look at xattred: https://eclecticlight.co/xattred-sandstrip-xattr-tools/

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Sat Jan 20, 2024 1:14 pm
by mk-soft
Create DMG (hdiutil)

Code: Select all

;-TOP by mk-soft, v1.01.0, 20.01.2024

; hdiutil create -volname WhatYouWantTheDiskToBeNamed -srcfolder /path/to/the/folder/you/want/to/create -ov -format UDZO name.dmg

; ----

Procedure CreateDMG(srcFolder.s, dmgFile.s, Title.s = "")
  Protected r1, program, destFolder.s, destFile.s, param.s, Output$
  
  If LCase(GetExtensionPart(dmgFile)) <> "dmg"
    dmgFile + ".dmg"
  EndIf
  
  destFolder = GetPathPart(dmgFile)
  destFile = GetFilePart(dmgFile)
  
  
  If Title = ""
    Title = GetFilePart(dmgFile, #PB_FileSystem_NoExtension)
  EndIf
  
  param = "create -volname " + #DQUOTE$ + Title + #DQUOTE$ + " -srcfolder " + #DQUOTE$ + srcFolder + #DQUOTE$
  param + " -ov -format UDZO " + #DQUOTE$ + dmgFile + #DQUOTE$
  
;   r1 = RunProgram("hdiutil", param, destFolder, #PB_Program_Wait)
  r1 = RunProgram("hdiutil", param, destFolder, #PB_Program_Open | #PB_Program_Read)
  Output$ = ""
  If r1
    While ProgramRunning(r1)
      If AvailableProgramOutput(r1)
        Output$ + ReadProgramString(r1) + Chr(13)
      EndIf
    Wend
    Output$ + Chr(13) + Chr(13)
    Output$ + "Exitcode: " + Str(ProgramExitCode(r1))
    CloseProgram(r1) ; Close the connection to the program
    ;MessageRequester("Output", Output$)
    If FileSize(dmgFile) < 0
      r1 = 0
    EndIf
  EndIf
  ProcedureReturn r1
EndProcedure

;- Main

Enumeration CustomEvent #PB_Event_FirstCustomValue
  #MyEvent_CreateDMG_Busy
  #MyEvent_CreateDMG_Done
  #MyEvent_CreateDMG_Error
  
EndEnumeration

Global srcFolder.s, dmgFile.s

Procedure thCreateDMG(*dummy)
  Protected r1
  PostEvent(#MyEvent_CreateDMG_Busy)
  r1 = CreateDMG(srcFolder, dmgFile)
  If r1
    PostEvent(#MyEvent_CreateDMG_Done)
  Else
    PostEvent(#MyEvent_CreateDMG_Error)
  EndIf
EndProcedure

Procedure Main()
  Protected dx, dy
  Protected r1, temp.s
  
  #WinStyle = #PB_Window_SystemMenu ; | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(0, #PB_Ignore, #PB_Ignore, 580, 140, "DMG Create", #WinStyle)
    ; MenuBar
    CreateMenu(0, WindowID(0))
    MenuTitle("File")
    
    ; StatusBar
    CreateStatusBar(0, WindowID(0))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(0)
    dy = WindowHeight(0) - StatusBarHeight(0) - MenuHeight()
    TextGadget(0, 10, 10, 100, 20, "Source Folder")
    StringGadget(1, 120, 8, 400, 25, "", #PB_String_ReadOnly)
    ButtonGadget(2, 530, 10, 40, 25, "./.")
    
    TextGadget(3, 10, 45, 100, 20, "DMG File Name")
    StringGadget(4, 120, 43, 400, 25, "", #PB_String_ReadOnly)
    ButtonGadget(5, 530, 45, 40, 25, "./.")
    
    ButtonGadget(6, 10, 80, 120, 30, "Create DMG")
    
    ; Main Loop
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case 0
              Break
          EndSelect
          
        Case #PB_Event_Menu
          Select EventMenu()
            
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case 2
              temp = PathRequester("Folder", "")
              If temp
                srcFolder = temp
                SetGadgetText(1, srcFolder)
              EndIf
              
            Case 5
              temp = SaveFileRequester("DMG File", "", "", 0)
              If temp
                dmgFile = temp
                If LCase(GetExtensionPart(dmgFile)) <> "dmg"
                  dmgFile + ".dmg"
                EndIf
                SetGadgetText(4, dmgFile)
              EndIf
              
            Case 6
              If dmgFile <> "" And FileSize(srcFolder) = -2
                If Not IsThread(r1)
                  r1 = CreateThread(@thCreateDMG(), 0)
                  If Not r1
                    MessageRequester("Create DMG", "Error Create Thread!")
                  EndIf
                EndIf
              EndIf
              
          EndSelect
          
        Case #MyEvent_CreateDMG_Busy
          StatusBarText(0, 0, "  Busy ...")
          
        Case #MyEvent_CreateDMG_Done
          StatusBarText(0, 0, "  Done.")
          MessageRequester("Create DMG", "Ready!")
          
        Case #MyEvent_CreateDMG_Error
          StatusBarText(0, 0, "  Error!")
          MessageRequester("Create DMG", "Error!")
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Sat Jan 20, 2024 1:19 pm
by Piero
Fred wrote: Thu Jan 18, 2024 9:01 am You need to notarize it as jamirokwai said.
Hey Fred, you know I'm your fan etc., but that does NOT help talented PB developers with a low budget to PB stuff on Mac!

PS: Mon cheri dans la tour Eiffel avec l'ordinateur

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Sat Jan 20, 2024 3:57 pm
by mrbungle
Notarization is an Apple requirement not a PB one.

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Sat Jan 20, 2024 4:07 pm
by Piero
mk-soft wrote: Sat Jan 20, 2024 1:14 pm r1 = RunProgram("hdiutil", param, destFolder, #PB_Program_Open | #PB_Program_Read)
EEEW! I just saw a runprogram parameter!

Jokes apart, some of you are probably thinking we are talking nonsense, if they cannot compile for ARM and test…

Re: Strange behaivour when unpacking my app from a downloaded zip file

Posted: Sat Jan 20, 2024 4:24 pm
by mk-soft
I don't have a Mac M1/M2

Have you tried the code ... Without immediately messing with the parameters.