How can I get the console logs from the iOS Simulator?

前端 未结 13 1578
感情败类
感情败类 2020-11-27 09:24

I want to see what happens in the iOS Simulator if I\'m not testing the app in Xcode.

For example, if I open a link in the Safari simulator, see what happens in the

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 10:06

    XCode > 6.0 AND iOS > 8.0 The below script works if you have XCode version > 8.0

    I use the below small Script to tail the simulator logs onto the system console.

    #!/bin/sh
    sim_dir=`xcrun instruments -s | grep "iPhone 6 (8.2 Simulator)" | awk {'print $NF'} | tr -d '[]'`
    tail -f ~/Library/Logs/CoreSimulator/$sim_dir/system.log
    

    You can pass in the simulator type used in the Grep as an argument. As mentioned in the above posts, there are simctl and instruments command to view the type of simulators available for use depending on the Xcode version. To View the list of available devices/simulators.

    xcrun instruments -s
    

    OR

    xcrun simctl list
    

    Now you can pass in the Device code OR Simulator type as an argument to the script and replace the "iPhone 6 (8.2 Simulator)" inside grep to be $1

提交回复
热议问题