4

When I create a new mobile app with Delphi, I have this dpr source:

program Project1;

uses
  System.StartUpCopy,
  FMX.Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

I do not understand, what the purpose of the System.StartUpCopy in the use? With System.StartUpCopy.pas, on ios, it's look like the app will copy file from

/private/var/containers/Bundle/Application/2BE5407C-4DD9-5A08-110F-C12510C42BF3/myapp.app/StartUp/Documents/

to

/private/var/mobile/Containers/Data/Application/2BE5407C-4DD9-5A08-110F-C12510C42BF3/Documents/

but I don't fully understand why because now my app will use twice more disk space, and my app can access both directories so I do not understand why we need to duplicate the resources :(

zeus
  • 12,173
  • 9
  • 63
  • 184
  • 2
    `StartupCopy` is what the Deployment Manager uses at runtime to copy deployed files to a local folder where your app can then access them. – Remy Lebeau May 21 '20 at 19:43
  • @RemyLebeau so my app will use double disk size ? why app can not access file located in /private/var/containers/Bundle/Application/2BE5407C-4DD9-5A08-110F-C12510C42BF3/myapp.app/StartUp/Documents/ and must copy those files in /private/var/mobile/Containers/Data/Application/2BE5407C-4DD9-5A08-110F-C12510C42BF3/Documents/ – zeus May 21 '20 at 19:53
  • `/private/var/containers/Bundle/Application/{uuid}` stores the actual bundle for your app, such as resources and assets. Deployed files are copied to the app's data folder in `/private/var/mobile/Containers/Data/Application/{uuid}` so the app can actually do work with them. – Remy Lebeau May 21 '20 at 20:22
  • @RemyLebeau yes resources are stored in /private/var/containers/Bundle/Application/{uuid} and actually when you access then via TResourceStream, you access them at this location. so what the purpose to copy them in /private/var/mobile/Containers/Data/Application/{uuid} ? it's a pain because if have around 15mb of resources for my app – zeus May 21 '20 at 20:25
  • Ask Embarcadero. `StartupCopy` is not documented, but it is well-known to be necessary for deployments to work properly. – Remy Lebeau May 21 '20 at 20:28
  • @RemyLebeau yes I will ask, but I try first here as many experts like you are here :) I just try to remove the System.StartUpCopy from my app and it's work perfectly – zeus May 21 '20 at 20:29
  • I don't have the source code for `System.StartupCopy.pas`, so I can't tell you exactly what it does or why. And it seems this is also an issue on OSX and Windows, too: [RSP-26369](https://quality.embarcadero.com/browse/RSP-26369). – Remy Lebeau May 21 '20 at 20:32
  • seam to be the same for android, look like it's useless to add System.StartUpCopy, will just duplicate all your resources files ! – zeus May 21 '20 at 21:10
  • 3
    "remove the System.StartUpCopy from my app and it's work perfectly". Even when the app is not on the device beforehand? – Dave Nottage May 22 '20 at 00:00
  • 3
    If you have large resources to deploy, and they are read-only, don't use the built-in solution in Delphi. It uses the StartUpCopy and doubles the file size. Instead add the files in the "Deployment" menu and access them directly inside the bundle. – Hans May 22 '20 at 07:07
  • @DaveNottage yes even in that case, i uninstall the app, reinstall it and it's work perfectly without the System.StartUpCopy. It's quite bad to have a this unit included in all mobile project without even a line of documentation explaining why this unit is here :( hans, i have more than 500 resources files (images mostly) and manage them in the deployment tool is really a pain! what delphi did with resource is good (put it in asset for android for example), but this System.StartUpCopy look crazy for me – zeus May 22 '20 at 08:01

0 Answers0