Question

The deployment page states launch images are stored in root.

However, all of the following paths return false when using FileExists so...

FileExists(TPath.GetHomePath + PathDelim + 'LaunchImage_320x480.png');
FileExists(TPath.GetHomePath + PathDelim + Application.Title + '.app' + PathDelim + 'LaunchImage_320x480.png'); 
FileExists(TPath.GetDocumentsPath + PathDelim + 'LaunchImage_320x480.png');
FileExists('' + 'LaunchImage_320x480.png');
FileExists('.\' + 'LaunchImage_320x480.png');
Was it helpful?

Solution

The launch images should be stored in the same folder as the application as described by the documentation. You should be able to get the filename using NSBundle.pathForResource.

uses
  iOSapi.Foundation, Macapi.Helpers;

procedure TForm1.FormCreate(Sender: TObject);
var
  FileName: string;
begin
  FileName := NSStrToStr(TNSBundle.Wrap(TNSBundle.OCClass.mainBundle).pathForResource(NSSTR('Default'), NSStr('png')));
  //....
end;

The trick might be that the filenames of the launch image are not necessarily identical to those in the IDE. You could list all the files in your application like this:

uses
  iOSapi.Foundation, Macapi.Helpers, System.IOUtils;

procedure TForm1.Button1Click(Sender: TObject);
var
  FileName: string;
  files: TStringDynArray;
  AppFolder: string;
  I: Integer;
begin
  AppFolder := NSStrToStr((TNSBundle.Wrap(TNSBundle.OCClass.mainBundle).bundlePath));
  Files := TDirectory.GetFiles(AppFolder);
  for I := 0 to Length(Files) - 1 do
    Memo1.Lines.Add(ExtractFileName(Files[I]));
end;

You could also use a tool like DiskAid in order to take a look at the iOS application folder on Windows.

OTHER TIPS

The default images are stored at this directory (you can find it using a terminal on MacOS)

DirPath := TPath.Combine(TPath.GetHomePath, Application.Title + '.app');

.

If you are asking for how to locate self-upload files, Here is the instruction:

  1. Click Project > Deployment from the main menu.
  2. Add wanted files by clicking Add files.
  3. Change the file location from .\ to StartUp\Documents\
  4. Click the Connect to Remote Machine button (after couple of seconds, the column Remote Status should show Missing
  5. Click the Deploy button and wait for Remote Status become Same

Now the file should be accessible from your application code:

ImagePath := TPath.Combine(TPath.GetDocumentsPath, 'LaunchImage_320x480.png');
if FileExists(ImagePath) then
  Image1.Bitmap.LoadFromFile(ImagePath);

Compile your code run it in your iOS device or an iOS simulator. It should work and have fun!

Notes:

  1. Filename is case sensitive on iOS.
  2. Do not upload .bmp to iOS, because I do not think iOS supports bitmap.
  3. The file location for an Andriod device is different. (but who cares)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top