Lazarus

Programming => Operating Systems => macOS / Mac OS X => Topic started by: ozznixon on June 02, 2018, 05:55:51 pm

Title: [Solved] On Mac .App TProcess Exec another .App?
Post by: ozznixon on June 02, 2018, 05:55:51 pm
I have the code working on Windows and Linux. However, due to Apple's App bundling, I am unable to have one Lazarus App, run Another Lazarus App.

* Now what I would like to do is deploy

MyProject.App
in \Contents\MacOS\ also include the binaries of the other Apps (modules for this project).

I have tried simply copying the binary into the MyProject.App/Contents/MacOS/ folder - can pass the Path to that Binary, and call the binary - without success.

I have tried to copy the module (IM.app) folder to MyProject.App/Contents/MacOS/ folder - without success.

Do I chain to Folder.App, or to Folder.App/Content/MacOS/Folder ?

Current EXEC code:
Code: Pascal  [Select][+][-]
  1. procedure Exec(Prog:String;SpkLargeButton:TSpkLargeButton);
  2. var
  3.    Proc:TProcess;
  4.  
  5. Begin
  6.    SpkLargeButton.Enabled:=False;
  7.    Proc:=TProcess.Create(Nil);
  8. {$IFDEF DARWIN}
  9.    Proc.CurrentDirectory:=ExtractFilePath(Paramstr(0))+Prog+'.app/Contents/MacOS/';
  10.    ShowMessage(Proc.CurrentDirectory);
  11. {$ELSE}
  12.    Proc.CurrentDirectory:=ExtractFilePath(Paramstr(0));
  13. {$ENDIF}
  14.    Proc.Executable:=Prog;
  15.    Proc.Active:=True;
  16.    while Proc.Running do begin
  17.       Application.ProcessMessages;
  18.       Sleep(1);
  19.    end;
  20. //   ShowMessage('Result code: '+IntToStr(Proc.ExitCode));
  21.    Proc.Free;
  22.    SpkLargeButton.Enabled:=True;
  23. end;
  24.  
Title: Re: On Mac .App TProcess Exec another .App?
Post by: Phil on June 02, 2018, 06:32:04 pm
I have the code working on Windows and Linux. However, due to Apple's App bundling, I am unable to have one Lazarus App, run Another Lazarus App.

To launch app 2 from app 1, shell out and run like this:

open path/to/app2.app

Title: Re: On Mac .App TProcess Exec another .App?
Post by: ozznixon on June 02, 2018, 06:41:59 pm
Thanks @phil ... forgot about /usr/bin/open.  ;-)
Title: Re: On Mac .App TProcess Exec another .App?
Post by: ozznixon on June 03, 2018, 06:55:13 am
To launch app 2 from app 1, shell out and run like this:

open path/to/app2.app

Any reason it is so much slower to chain to another executable under Mac OSX, compared to Windows or Linux? Especially when the Mac is a much faster system (physical hardware is). 3 second count, vs. the others feel like a DDL load (less than 500ms).

Thanks!
Ozz
TinyPortal © 2005-2018