From f92d194a8decb573d436545c7bd6f4195db6bb94 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Fri, 1 Jan 2016 19:18:18 +0000 Subject: [PATCH] iphonelazext: fixed installation process, using simctl install to actually install an application to the simulator git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4413 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/iphonelazext/ideext.pas | 2 +- components/iphonelazext/iphonesimctrl.pas | 63 +++++++++++++++++++++-- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/components/iphonelazext/ideext.pas b/components/iphonelazext/ideext.pas index 0d50c3d72..137d0c2cb 100644 --- a/components/iphonelazext/ideext.pas +++ b/components/iphonelazext/ideext.pas @@ -516,7 +516,7 @@ begin prj := GetXcodeProjDirName; IDEMsg('Build+Install Xcode project (xcodebuild)'); - if not InstallXcodePrj(prj, 'iphonesimulator') then begin + if not InstallXcodePrj(prj, 'iphonesimulator', EnvOptions.DefaultDeviceID) then begin IDEMsg('xcodebuild failed'); Exit; end else diff --git a/components/iphonelazext/iphonesimctrl.pas b/components/iphonelazext/iphonesimctrl.pas index 98b9b396d..f713664cf 100644 --- a/components/iphonelazext/iphonesimctrl.pas +++ b/components/iphonelazext/iphonesimctrl.pas @@ -28,7 +28,7 @@ type function ListDevice(lst: TList): Boolean; -function InstallXcodePrj(const project, sdk: string): Boolean; +function InstallXcodePrj(const project, sdk, deviceid: string): Boolean; type { TRWProcess } @@ -242,14 +242,67 @@ begin end; end; -function InstallXcodePrj(const project, sdk: string): Boolean; +function checkOptVal(const s: string; nm: string; var vl: string): Boolean; +var + i : integer; +begin + i:=Pos(nm, s); + Result:=(i>0); + if not Result then Exit; + //if i<0 then + inc(i, length(nm)); + for i:=i to length(s) do + if s[i]='=' then begin + vl:=trim(Copy(s, i+1, length(s))); + Result:=true; + Exit; + end; + Result:=false; +end; + +function InstallXcodePrj(const project, sdk, deviceid: string): Boolean; var outstr: string; + s : string; + l : string; + st : TStringList; + i : integer; + j : integer; + ip : string; // install path + fp : string; // content path begin - writeln('project = ', project); - writeln('sdk = ', sdk); - Result:=RunCommand('xcodebuild', ['install', '-project' ,project, '-sdk',sdk], outstr); + Result:=RunCommand('xcodebuild', + ['install' + ,'-project' ,project, '-sdk',sdk], outstr); + if not Result then Exit; + + Result:=RunCommand('xcodebuild', + ['install' + ,'-project' ,project, '-sdk',sdk + ,'-showBuildSettings'], outstr); + st:=TStringList.Create; + try + st.Text:=outstr; + ip:=''; + fp:=''; + for i:=st.Count-1 downto 0 do begin + s:=st[i]; + l:=AnsiLowerCase(s); + if (ip='') then checkOptVal(s, 'INSTALL_DIR', ip); + if (fp='') then checkOptVal(s, 'CONTENTS_FOLDER_PATH', fp); + if pos('build settings for', l)>0 then Break; + end; + finally + st.Free; + end; + Result:=(ip<>'') and (fp<>''); + + if Result then begin + Result:=RunCommand('xcrun', + ['simctl','install' + ,deviceid, IncludeTrailingPathDelimiter(ip)+fp ], outstr); + end; end; Const