With JQ installed - output of this command is string with quotes
xcrun simctl list --json | jq '.devices["iOS 12.0"] [] | select(.name=="iPhone X") | .udid'
With JQ if you don't want quotes
| #!/bin/bash | |
| # This script archive 2 things here | |
| # 1. boot the fresh simulator once, so we can reduce the boot time in UI test | |
| # 2. Simulator shows swipe tutorial on first use of keyboard (iOS13 above), this script will set simulator preferences so it wont show the tutorial | |
| function get_simulator_udid() { | |
| echo '' | xcrun simctl list devices | grep "iPhone" | grep -v "unavailable" | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | |
| } |
| 2020-03-03 15:49:44.579009-0800 WebDriverAgentRunner-Runner[13001:2373474] The following attributes were requested to be included into the XML: {( | |
| FBEnabledAttribute, | |
| FBVisibleAttribute, | |
| FBXAttribute, | |
| FBYAttribute, | |
| FBWidthAttribute, | |
| FBHeightAttribute, | |
| FBTypeAttribute, | |
| FBValueAttribute, | |
| FBNameAttribute, |
| # Redirect console output to a file and display on console at the same time. | |
| bundle exec fastlane <your_lane_here> --verbose 2>&1 | tee /path/to/logfile.txt |
| # Install snapshot gem | |
| gem install snapshot | |
| # Reset all the simulators | |
| fastlane snapshot reset_simulators |
| # to list the sessions and their status | |
| screen -ls | |
| # to start a session with a given name. The name should be unique | |
| screen -S session_name | |
| # to start a session without going into it | |
| screen -dmS session_name /path/to/script/file.sh |
| erase_sim: | |
| ./reset_sim.sh 2>/dev/null; true |
| // Copied from https://stackoverflow.com/a/49944637 | |
| import XCTest | |
| enum TestSwipeDirections { | |
| case up | |
| case down | |
| case left | |
| case right | |
| } |
| extension XCUIApplication { | |
| private struct Constants { | |
| // Half way accross the screen and 10% from top | |
| static let topOffset = CGVector(dx: 0.5, dy: 0.1) | |
| // Half way accross the screen and 90% from top | |
| static let bottomOffset = CGVector(dx: 0.5, dy: 0.9) | |
| } | |
| var screenTopCoordinate: XCUICoordinate { |
With JQ installed - output of this command is string with quotes
xcrun simctl list --json | jq '.devices["iOS 12.0"] [] | select(.name=="iPhone X") | .udid'
With JQ if you don't want quotes
$ cat a.txt
hello
This line starts with T and finishes with e
foo