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 console,
or if I install a web-app, see the links that I'm pressing in console.
How can I do this?
I want to see it in Xcode or Terminal, but it's not a problem if I need to use another bit of software.
iOS Simulator > Menu Bar > Debug > Open System Log
Old ways:
iOS Simulator prints its logs directly to stdout, so you can see the logs mixed up with system logs.
Open the Terminal and type: tail -f /var/log/system.log
Then run the simulator.
EDIT:
This stopped working on Mavericks/Xcode 5. Now you can access the simulator logs in its own folder: ~/Library/Logs/iOS Simulator/<sim-version>/system.log
You can either use the Console.app to see this, or just do a tail (iOS 7.0.3 64 bits for example):
tail -f ~/Library/Logs/iOS\ Simulator/7.0.3-64/system.log
EDIT 2:
They are now located in ~/Library/Logs/CoreSimulator/<simulator-hash>/system.log
tail -f ~/Library/Logs/CoreSimulator/<simulator-hash>/system.log
You can view the console for the iOS Simulator via desktop Safari. It's similar to the way you use desktop Safari to view the console for physical iOS devices.
Whenever the simulator is running and there's a webpage open, there'll be an option under the Develop menu in desktop safari that lets you see the iOS simulator console:
Develop -> iPhone Simulator -> site name
There's an option in the Simulator to open the console
Debug > Open System Log
or use the
keyboard shortcut: ⌘/
iOS 8 and iOS 9
Under iOS 8 and iOS 9 this location is now:
~/Library/Logs/CoreSimulator/<DEVICE_CODE>
So, the following will work:
tail -f ~/Library/Logs/CoreSimulator/<DEVICE_CODE>/system.log
The DEVICE_CODE value can be found via the following terminal command:
instruments -s devices
You should not rely on instruments -s. The officially supported tool for working with Simulators from the command line is xcrun simctl.
The log directory for a device can be found with xcrun simctl getenv booted SIMULATOR_LOG_ROOT. This will always be correct even if the location changes.
Now that things are moving to os_log it is easier to open Console.app on the host Mac. Booted simulators should show up as a log source on the left, just like physical devices. You can also run log commands in the booted simulator:
# os_log equivalent of tail -f
xcrun simctl spawn booted log stream --level=debug
# filter log output
xcrun simctl spawn booted log stream --predicate 'processImagePath endswith "myapp"'
xcrun simctl spawn booted log stream --predicate 'eventMessage contains "error" and messageType == info'
# a log dump that Console.app can open
xcrun simctl spawn booted log collect
# open location where log collect will write the dump
cd `xcrun simctl getenv booted SIMULATOR_SHARED_RESOURCES_DIRECTORY`
If you want to use Safari Developer tools (including the JS console) with a webpage in the Simulator: Start one of the simulators, open Safari, then go to Safari on your mac and you should see Simulator in the menu.
You can open a URL in the Simulator by dragging it from the Safari address bar and dropping on the Simulator window. You can also use xcrun simctl openurl booted <url>.
[iOS Logger]
You can use the Console application(select your device in Devices) on your Mac to see a log message that were sent using NSLog, os_log, Logger (you will not see logs from print function).
Also please check (Action -> Include <Info/Debug> Messages)
Please note that if you want to see a log from WebView(UIWebView or WKWebView) you should use Safary -> Develop -> device
[Find crash log]
If you are using Swift, remember that println will only print to the debug log (which appears in xCode's debug area). If you want to print to system.log, you have to use NSLog as in the old days.
Then you can view the simulator log via its menu, Debug > Open System Log... (cmd + /)
tailing /var/log/system.log didn't work for me. I found my logs by using Console.app. They were in
~/Library/Logs/iOS Simulator/{version}/system.log
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
You can see the Simulator console window, including Safari Web Inspector and all the Web Development Tools by using the Safari Technology Preview app.
Open your page in Safari on the Simulator and then go to Safari Technology Preview > Develop > Simulator.
In Xcode:
View->Debug Area->Activate Console
I can open the log directly via the iOS simulator: Debug -> Open System Log... Not sure when this was introduced, so it might not be available for earlier versions.
No NSLog or print content will write to system.log, which can be open by Select Simulator -> Debug -> Open System log on Xcode 11.
I figure out a way, write logs into a file and open the xx.log with Terminal.app.Then the logs will present in Terminal.app lively.
I use CocoaLumberjack achieve this.
STEP 1:
Add DDFileLogger DDOSLogger and print logs path. config() should be called when App lunch.
static func config() {
#if DEBUG
DDLog.add(DDOSLogger.sharedInstance) // Uses os_log
let fileLogger: DDFileLogger = DDFileLogger() // File Logger
fileLogger.rollingFrequency = 60 * 60 * 24 // 24 hours
fileLogger.logFileManager.maximumNumberOfLogFiles = 7
DDLog.add(fileLogger)
DDLogInfo("DEBUG LOG PATH: " + (fileLogger.currentLogFileInfo?.filePath ?? ""))
#endif
}
STEP 2:
Replace print or NSLog with DDLogXXX.
STEP 3:
$ tail -f {path of log}
Here, message will present in Terminal.app lively.
One thing more. If there is no any message log out, make sure Environment Variables -> OS_ACTIVITY_MODE ISNOT disable.
Download the safari technology review. With the simulator running, select develop > simulator > localhost
The easiest way to see the console logs is by adding consolelogs as a param:
ionic cordova run ios -l --consolelogs
And you'll able to see the console logs in your terminal.
Related
I have an issue. I started to code in Android Studio and I want to select iOS Simulator. However, I can select only option Open iOS Simulator which opens.. a watch!
How could I launch a phone as a simulator?
I tried going into Simulator itself, but couldn't find any ways how to do it.
Open iOS Simulator externally first. Now, open Xcode, Select your latest Xcode version in Xcode -> Preferences -> Locations -> Command Line Tools
Now, go to Terminal and run flutter doctor See if it shows any iOS device connected.
If yes, then you're done. Now you can see opened simulator can be seen in Flutter Device Selection and used to run your flutter application in iOS Simulator.
If No, then open terminal of project and run xcrun simctl list, from list of devices copy UID of wanted device and run xcrun simctl boot *SELECTED_UID*
After extensive research, I found a solution.
First, go to your xcode.
xcode -> Preferences -> Components and install selected iOS version.
After installation is finished, head to Android Studio go to Terminal tab and write xcrun simctl list - you will get list of devices. Select which one you want to use, copy UID (bunch of numbers) and use it with this command xcrun simctl boot *YOUR_DEVICE_ID*
Hope it helps for someone with same issue!
Sometimes, Xcode will not install Apps in the simulator, giving nothing more than the message "This app could not be installed at this time.".
The simulator writes a log for the events that occur while installing an App.
To access it, list the available simulators by typing this in the terminal:
instruments -s devices
this will give you a list with entries like
iPad Pro (10.5-inch) (11.4) [75DE3247-4641-4D71-BAC1-3EC3B019FC87] (Simulator)
Copy the uuid between the brackets for the simulator you are using.
Then type
cd ~/Library/Logs/CoreSimulator/<THE-UUID-YOU-JUST-COPIED>/MobileInstallation
You are now in a directory, that contains the installation logs.
Open the newest log and look for errors of your installation (most likely at the end of the log).
First Reset the simulator by following option:
Hardware -> Erase All content and settings...
and then clean your project by following commands:
shift+cmd+K
shift+opt+cmd+K
If you still want to know what exactly causing the issue, you can check at log files from below location:
~/Library/Logs/CoreSimulator/
While I'm running UITests on Simulator with Xcode 7, it's failed when invoking XCUIApplication().launch() with App accessibility isn't loaded
this is a known bug in Xcode bot, usually happens on large server code bases. It's already been filed by Apple Developers (myself as well), and they're 'fixing' it.
Hope this helps.
If you run tests inside CI system under your control, you could possibly reset simulators before running the UI tests. That way the bug is workarounded.
You could reset simulators from command line with following command:
xcrun simctl list | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl erase uuid
As pointed in this SO thread you could also use(however I didn't try it):
xcrun simctl erase all
Restarting the device got rid of this issue for me. (I was using a real device not a simulator)
I got this error following a crash in the test app in CI. In my case, I successfully reproduced the issue locally, then it was easy to see that it crashes (a crash alert appears) and to investigate and fix the error.
In my case the alert was also written to stderr, but on the CI it was not redirected to the logs. If I couldn't repro locally, my next step was to find a way to redirect stderr & stdout to logs.
I might be going about this wrong, but I am trying to run an iOS app in the Xcode 6 iOS simulator in order to record a video tutorial of the app.
I have xCode installed and can launch the iOS simulator, but there seems to be no way to install an .app file. The ~/Library/Developer/CoreSimulator folder is a complete mystery and there is no clear location to drop the app files.
Any ideas?
Alternatively, is there an easier way to record a video of your iOS app? People must do it all the time for tutorials...
Thanks
If you were running the app on a device, you could use the new Yosemite feature to record over USB to QuickTime.
However, as you are using the simulator, you will need to a partial screen recording in QuickTime.
Using QuickTime
Launch QuickTime then go to File > New Screen Recording. You can either click to select the whole screen, or drag to only record a portion of the screen.
Alternatives
If you want more flexibility, you will need to use 3rd party software like ScreenFlow.
From Xcode 8.2,You can take a screenshot or record a video of the simulator window using the xcrun command-line utility.
Launch your app in Simulator.
Launch Terminal (located in /Applications/Utilities), and enter the appropriate command:
To take a screenshot, use the screenshot operation:
xcrun simctl io booted screenshot
You can specify an optional filename at the end of the command.
To record a video, use the recordVideo operation:
xcrun simctl io booted recordVideo <filename>.<extension>
To stop recording, press Control-C in Terminal.
Note: You must specify a filename for recordVideo.
The default location for the created file is the current directory.
For more information on simctl, run this command in Terminal:
xcrun simctl help
For more information on the io subcommand of simctl, run this command:
xcrun simctl io help
Check this link for more details.
You can use 'Build & Run' in Xcode to install and run your app in the iOS Simualtor.
Alternatively, you can run xcrun simctl install <Device UDID> <Path to app> to install your app. See xcrun simctl help for more information.
Regarding recording a screen capture video, you should use QuickTime.
Is there a way to view the real-time console log to view NSLog and other debug messages in a real-time manner, such as adb logcat?
The solution documented by Apple in Technical Q&A QA1747 Debugging Deployed iOS Apps for Xcode 6 is:
Choose Window -> Devices from the Xcode menu.
Choose the device in the left column.
Click the up-triangle at the bottom left of the right hand panel to show the device console.
Two options:
libimobiledevice is installable via homebrew and works great. Its idevicesyslog tool works similarly to deviceconsole (below), and it supports wirelessly viewing your device's syslog (!)
I've written more about that on Tumblr tl;dr:
brew install libimobiledevice
idevice_id --list // list available device UDIDs
idevicesyslog -u <device udid>
with the device connected via USB or available on the local wireless network.
(Keeping for the historical record, from 2013:) deviceconsole from rpetrich is a much less wacked-out solution than ideviceconsole above. My fork of it builds and runs in Xcode 5 out of the box, and the Build action will install the binary to /usr/local/bin for ease of use.
As an additional helpful bit of info, I use it in the following style which makes it easy to find the device I want in my shell history and removes unnecessary > lines that deviceconsole prints out.
deviceconsole -d -u <device UDID> | uniq -u && echo "<device name>"
EDIT: Please use #cbowns solution - deviceconsole is compatible with iOS9 and much easier to use.
This is a open-source program that displays the iDevice's system log in Terminal (in a manner similar to tail -F). No jailbreak is required, and the output is fully grep'able so you can filter to see output from your program only. What's particularly good about this solution is you can view the log whether or not the app was launched in debug mode from XCode.
Here's how:
Grab the libimobiledevice binary for Mac OS X from my github account at
https://github.com/benvium/libimobiledevice-macosx/zipball/master
Follow the install instructions here:
https://github.com/benvium/libimobiledevice-macosx/blob/master/README.md
Connect your device, open up Terminal.app and type:
idevicesyslog
Up pops a real-time display of the device's system log.
With it being a console app, you can filter the log using unix commands, such as grep
For instance, see all log messages from a particular app:
idevicesyslog | grep myappname
Taken from my blog at http://pervasivecode.blogspot.co.uk/2012/06/view-log-output-of-any-app-on-iphone-or.html
Just open the Application Console.app on mac osX.
You can find it under Applications > Utilities > Console.
On the left side of the application all your connected devices are listed.
Try the freeware iOS Console. Just download, launch, connect your device -- et voila!
This might be what you're looking for: Xcode Organizer
device > terminal output is on iPhone configuration app
here: http://support.apple.com/kb/DL1465
You have three options:
Xcode Organizer
Jailbroken device with syslogd + openSSH
Use dup2 to redirect all STDERR and STDOUT to a file and then "tail -f" that file (this last one is more a simulator thing, since you are stuck with the same problem of tailing a file on the device).
So, to get the 2º one you just need to install syslogd and OpenSSH from Cydia, restart required after to get syslogd going; now just open a ssh session to your device (via terminal or putty on windows), and type "tail -f /var/log/syslog". And there you go, wireless real time system log.
If you would like to try the 3º just search for "dup2" online, it's a system call.
To view your iOS device's console in Safari on your Mac (Mac only apparently):
On your iOS device, go to Settings > Safari > Advanced and switch on Web Inspector
On your iOS device, load your web page in Safari
Connect your device directly to your Mac
On your Mac, if you've not already got Safari's Developer menu activated, go to Preferences > Advanced, and select "Show Develop menu in menu bar"
On your Mac, go to Develop > [your iOS device name] > [your web page]
Safari's Inspector will appear showing a console for your iOS device.
As an alternative, you can use an on-screen logging tool like ticker-log to view logs without having (convenient) access to the console.