How deploy a OSX or IOS Delphi project from the Command line?
Asked Answered
D

4

6

I'm building my Delphi Apps using a script like

call "C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\bin\rsvars.bat"
msbuild.exe "C:\Projects\Foo\Bar.dproj"

And now I want add an option to deploy the application to an OSX (or IOS) system modifing such script, so is possible deploy a OSX or IOS Delphi project from the Command line?

Decolorant answered 19/8, 2013 at 19:40 Comment(2)
For building the project; have you tried something like msbuild Project.dproj /p:Config=Release;Platform=OSX32 ?Dismissal
But that only changes the building settings, and doesn't deploy the Application in the target.Decolorant
C
6

To deploy your application to a remote location , you must use the paclient.exe (Platform Assistant Client Application) tool.

In order to get the passed parameters Build and Run you project from RAD Studio and then check the Build tab of the message windows of the IDE.

Check the next image for a OSX Application using a profile called Local

enter image description here

From here you can extract all the parameters passed to the paclient.exe

  • Delete in the host the previous files (is exists)

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --Clean="Project7.app,C:\Users\RRUZ\Desktop\Test Deploy_@emb_.tmp"

the _@emb_.tmp file is a temp file created by the ide that contains all the files to deploy in this case the content is like so

Project7.app\Contents\MacOS\Project7.rsm
Project7.app\Contents\Entitlements.plist
Project7.app\Contents\MacOS\libcgunwind.1.0.dylib
Project7.app\Contents\MacOS\Project7
Project7.app\Contents\Resources\Project7.icns
  • Copy the Info.plist (contains settup info the the .app like the icon used and the version) file to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7.info.plist,Project7.app\Contents\,1,Info.plist" Local

  • Copy the libcgunwind.1.0.dylib file (library) to the host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="c:\program files (x86)\embarcadero\rad studio\11.0\Redist\osx32\libcgunwind.1.0.dylib,Project7.app\Contents\MacOS\,1,libcgunwind.1.0.dylib" Local

  • Copy the bundler to the host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7,Project7.app\Contents\MacOS\,1,Project7" Local

  • Copy the Remote debug symbols file to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7.rsm,Project7.app\Contents\MacOS\,1,Project7.rsm" Local

  • Copy the project icon to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="c:\program files (x86)\embarcadero\rad studio\11.0\bin\delphi_PROJECTICNS.icns,Project7.app\Contents\Resources\,1,Project7.icns" Local

  • Copy the Entitlements.plist file to the Host

c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe --put="OSX32\Debug\Project7.entitlements,Project7.app\Contents\,1,Entitlements.plist" Local

Final script

Finally you can put all this in a script file like so

call "C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\bin\rsvars.bat"
MSBuild Project7.dproj 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --Clean="Project7.app,C:\Users\RRUZ\Desktop\Test Deploy\files.txt"  
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7.info.plist,Project7.app\Contents\,1,Info.plist" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="c:\program files (x86)\embarcadero\rad studio\11.0\Redist\osx32\libcgunwind.1.0.dylib,Project7.app\Contents\MacOS\,1,libcgunwind.1.0.dylib" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7,Project7.app\Contents\MacOS\,1,Project7" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7.rsm,Project7.app\Contents\MacOS\,1,Project7.rsm" Local
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="c:\program files (x86)\embarcadero\rad studio\11.0\bin\delphi_PROJECTICNS.icns,Project7.app\Contents\Resources\,1,Project7.icns" Local 
"c:\program files (x86)\embarcadero\rad studio\11.0\bin\paclient.exe" --put="OSX32\Debug\Project7.entitlements,Project7.app\Contents\,1,Entitlements.plist" Local 

Note : Remember create a file with the file names of all the files to deploy , in this sample script is called files.txt, this file is use by the paclient to cleanup previus deployed files.

Chaetopod answered 24/8, 2013 at 4:10 Comment(0)
T
2

This answer is late, but I thought it might still be useful for other people. As part of a build script I also wanted to deploy a project automatically to OSX, but it is not directly possible with msbuild or Embarcadero's paclient.exe tool.

I wrote a helper command line tool called Embdeploy to automate the task. The source and a compiled binary are available on GitHub.

Here is some sample usage:

embdeploy.exe -deploy myproject.dproj
embdeploy.exe -platform OSX32 -config Release -deploy myproject.dproj
embdeploy.exe -profile <remote profile> -platform OSX32 -deploy myproject.dproj

The Embdeploy tool parses the .dproj file, which is XML, and generates a list of files to be copied for the specified configuration, platform, etc. It also detects the default platform, profile, configuration from the project if they are not given in the command line. You can define the deployment options in the Delphi IDE and then use the tool to do the deployment automatically.
To clean the remote project folder and do the actual deployment the tool uses paclient.exe and executes it with the appropriate parameters. Paclient.exe is detected from Delphi's install path.

There is another issue that the tool solves for me. My project includes additional bundled binaries, which are deployed with the app, but the Delphi IDE doesn't give enough control in this case. E.g. it deploys the additional binaries, but it doesn't set the Execute permission on the OSX, which has to be set by hand later. It is also not possible to 'codesign' those binaries and this is required for publishing the app to the Appstore.

To fix that I added the functionality to execute custom commands on the remote machine after deploying the file.
This is done like this:

embdeploy.exe -cmd "chmod +x myproject.app/Contents/MacOS/somebinary" myproject.dproj
embdeploy.exe -cmd "codesign .... myproject.app/Contents/MacOS/somebinary" myproject.dproj

This is done again with paclient.exe. The Embarcadero tool provides an option to deploy a script file, execute it and then delete it. I used this to execute my own commands by making a temporary shell file with the command, deploying it and executing it.
This way I could use "chmod", "productbuild" and whatever else I needed.

The tool is a bit basic and not optimized currently as I wrote it for my immediate needs, but I plan to expand it with a few more features. E.g. making a ZIP file of the OSX application bundle on Windows.

Tamarau answered 25/12, 2013 at 22:2 Comment(1)
Great tool! I found that a blog has been written based on your answer: kouraklis.com/2016/09/…Naos
U
0

Why not use the existing msbuild target Deploy?

msbuild.exe ".\path\projectname.dproj" /target:Deploy /p:Configuration=Release /p:Platform=Win64

This way you can use the deployment tool inside the IDE to make any changes necessary and not have to make changes to the cmd script suggested by RRUZ.

Underquote answered 18/2 at 19:20 Comment(0)
C
-1

First of all this is not a question regarding Delphi, It has more to do with Scripting in windows.

So, if you can access OSX within your operating system then you probably need only to copy required files directly to the folders where they should reside in the target operating system.

For IOS probably you won't be able to compile directly within windows. As far as I remember you export your code to a code that could be compiled in xCode targeting IOS (a requirement of Apple).

Condescending answered 23/8, 2013 at 21:54 Comment(1)
-1. You obviously aren't familiar with Delphi XE4, which directly compiles OSX and iOS applications on Windows (although it requires a system running one of those operating systems in order to test/debug/deploy). Yes, it directly compiles iOS applications. :-) See the XE4 product page for more information. (I'm not affiliated in any way with EMBT or Delphi, for clarity. I just object to people making statements that are totally incorrect, especially on technical sites geared toward professionals.)Shilashilha

© 2022 - 2024 — McMap. All rights reserved.