iOSで住所から位置情報を取得しようとすると強制終了してしまう

解決


のぶ  2021-07-07 02:02:00  No: 149787  IP: 192.*.*.*

TGeocoderのGeocodeメソッドに例えば住所に「あ」と設定し、
引数に渡すとiOSアプリが強制終了してしまいます。エラートラップにも引っ掛かりません。
実際の事例は個人情報になりますので記載しにくいですが、
実在の住所を入力しても最後の「○○号室」を追加すると強制終了したりします。
どなたか対処方法が分かる方はいらっしゃいますでしょうか。

procedure TForm1.Button1Click(Sender: TObject);
var
  CivicAddress: TCivicAddress;
begin
  if FGeocoder = nil then
    FGeocoder := TGeocoder.Current.Create;
  if Assigned(FGeocoder) then
    FGeocoder.OnGeocode := OnGeocode;
  CivicAddress := TCivicAddress.Create;
  CivicAddress.Address := Edit1.Text;
  if Assigned(FGeocoder) and not FGeocoder.Geocoding then begin
    try
      FGeocoder.Geocode(FAddress);
    except
    end;
  end;
  CivicAddress.Free;
end;

procedure TForm1.OnGeocode(const Coords: TArray<TLocationCoord2D>);
var
  LocationCoord2D: TLocationCoord2D;
begin
  if Length(Coords) > 0 then begin
    LocationCoord2D := Coords[0];
  end;
end;

編集 削除
igy  2021-07-07 09:38:56  No: 149789  IP: 192.*.*.*

お使いのDelphi のバージョンは、何ですか?
また、iOSのバージョンも・・

編集 削除
のぶ  2021-07-07 12:02:11  No: 149790  IP: 192.*.*.*

igyさん
ご返信いただきまして大変ありがとうございます。
度々すみません。
下記、ご指摘いただいた情報を記載いたします。
最新はDelphi 10.4.2と思いますが、まだ適用しておりません。

【Delphiバージョン】
Embarcadero® Delphi 10.4 バージョン 27.0.38860.1461 
インストール済みの更新
Delphi 10.4 and C++ Builder 10.4 Update 1

【iOSバージョン】
iOS 14.6

【GetItパッケージマネージャ(インストール済み)】
Embarcadero® Delphi 10.4 バージョン 27.0.38860.1461 
Apple Platforms Patch for RAD Studio 10.4.1 1.0
December Apple Platforms Patch for RAD Studio 10.4.1 1.0
Delphi Compiler and LSP Hotfix for 10.4.1 (General) 1
Delphi Compiler and LSP Hotfix for 10.4.1 (Linux) 1

編集 削除
igy  2021-07-07 12:23:13  No: 149791  IP: 192.*.*.*

関係ないかもしれませんが、10.4.2の「新機能と修正された問題」
New features and customer reported issues fixed in RAD Studio 10.4.2
http://docwiki.embarcadero.com/RADStudio/Sydney/en/New_features_and_customer_reported_issues_fixed_in_RAD_Studio_10.4.2
を見ると、

[iOS] TiOSGeocoder.GeocodeForwardHandler can cause a crash 
RSP-30483
https://quality.embarcadero.com/browse/RSP-30483

があるようです。

編集 削除
のぶ  2021-07-07 13:05:45  No: 149792  IP: 192.*.*.*

igyさん
ご回答大変ありがとうございます。
試してみる価値は大いにありそうですね。
すぐに10.4.2を適用することが難しい状況であるため、
後日、結果をこちらのスレッドに追記する形でご報告したいと思います。

編集 削除
のぶ  2021-10-11 01:08:30  No: 149877  IP: 192.*.*.*

Delphiを下記最新にバージョンアップして試したところ、iOSアプリが強制終了しなくなりました。
下記イベントの「Coords」が参照できない不具合でしたが、
Length(Coords) = 0 と、参照できるようになり、住所から位置情報取得ができない場合に
イベントで拾えるようになりました。
以上、ご報告でした。

procedure TForm1.OnGeocode(const Coords: TArray<TLocationCoord2D>);
var
  Location: TLocationCoord2D;
begin
  if Length(Coords) = 0 then begin
    showmessage('位置情報を取得できませんでした。'); 
    exit;
  end;
                 :


【バージョン】
RAD Studio 11 Alexandria
Embarcadero® Delphi 11.0 バージョン 28.0.42600.6491

編集 削除