如何在iOS模拟器中直接运行应用程序时查看日志?

Boo*_*oon 3 xcode ios-simulator

我想直接在iOS模拟器中运行一个应用程序,并查看从NSLog发出的日志(而不是从Xcode运行应用程序).我怎样才能做到这一点?

Jer*_*oia 5

根据运行时版本,您可以使用以下之一:

xcrun simctl spawn booted syslog -w
xcrun simctl spawn booted log stream
tail -F "$(xcrun simctl getenv booted SIMULATOR_LOG_ROOT)/system.log"
Run Code Online (Sandbox Code Playgroud)

如果您在macOS Sierra上,还可以从Console.app中选择模拟设备以查看日志.