ios真機執行時儲存日誌並輸出

2021-10-05 20:27:57 字數 1447 閱讀 5384

(斷開xcode進行真機測試時,無法通過xcode看到執行日誌)

-

(void

)redirectnslogtodocumentfolder

uidevice *device =

[uidevice currentdevice];if

([[device model] hassuffix:

@"simulator"])

//獲取document目錄下的log資料夾,若沒有則新建

nsarray *paths =

nssearchpathfordirectoriesindomains

(nsdocumentdirectory, nsuserdomainmask, yes)

; nsstring *logdirectory =

[[paths objectatindex:

0@"log"];

nsfilemanager *filemanager =

[nsfilemanager defaultmanager]

; bool fileexists =

[filemanager fileexistsatpath:logdirectory];if

(!fileexists)

nsdateformatter *formatter =

[[nsdateformatter alloc] init]

;[formatter setlocale:

[[nslocale alloc] initwithlocaleidentifier:

@"zh_cn"]]

;[formatter setdateformat:

@"yyyy-mm-dd hh:mm:ss"];

//每次啟動後都儲存乙個新的日誌檔案中

nsstring *datestr =

[formatter stringfromdate:

[nsdate date]];

nsstring *logfilepath =

@"/%@.txt"

,datestr]

;// freopen 重定向輸出輸出流,將log輸入到檔案

freopen

([logfilepath cstringusingencoding:nsasciistringencoding]

,"a+"

,stdout);

freopen

([logfilepath cstringusingencoding:nsasciistringencoding]

,"a+"

,stderr);

}

選中log資料夾,點「儲存」,預設以.txt格式儲存在「文稿」下

appium 鏈結真機執行時報錯

解決辦法 還在找原因,後續更新進來。2.修改原始碼檔案如下 b.在adb.js的1035行找到 this.shell ps name function err,stdout 並增加上面用到的shell grep函式 adb.prototype.shell grep function cmd,grep...

React Native在真機執行(IOS)

如果之前在模擬器除錯過,換成真機執行的時候務必關閉模擬器 需要修改的配置 bundle identifier 修改為 com.soho3q 如果上來就執行的話,會報錯 改完介面 修改如下 確認目標裝置的系統版本一致 同樣也要確認tests測試用例專案下的配置 開啟info.plist檔案 值改為ye...

虛擬機器執行時資料區劃分

假設 新建company類,然後繼續 建立company例項,即company company new company 下面解釋 兩部動作所涉及到的虛擬機器執行時記憶體區域劃分 1,方法區 存放類資訊,常量,靜態變數 中新建類 類資訊 存放在方法去中 2,虛擬機器棧 建立棧幀,存放區域性變數資訊表,...