More Related Content Similar to Simulator customizing & testing for Xcode 9 (20) More from Bongwon Lee (8) Simulator customizing & testing for Xcode 93. Simulator allows you to rapidly prototype and
test builds of your app during the development process.
5. open -a Simulator
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
open -a Simulator --args -CurrentDeviceUDID $UDID
22. $ xcrun simctl list
$ xcrun simctl list devicetypes
$ xcrun simctl list -j runtimes
$ xcrun simctl list devices | grep Booted
xcrun simctl list [-j | ——json] [devices|devicetypes|runtimes|pairs]
24. xcrun simctl delete <device> [… <device n>] | unavailable
$ xcrun simctl delete 1418D7BD-CD6E-4C8A-AF95-580680AD5B2A
Delete
28. $ xcrun simctl create 'Giftbott X' <- name
com.apple.CoreSimulator.SimDeviceType.iPhone-X <- device type id
com.apple.CoreSimulator.SimRuntime.iOS-11-1 <- runtime id
xcrun simctl create <name> <device type id> <runtime id>
30. $ xcrun simctl rename 9E7DEEE4-035D-4CBC-B468-61D4D62618E7 'mySimulator'
xcrun simctl rename <device> <name>
xcrun simctl clone <device> <new name>
$ xcrun simctl clone 9E7DEEE4-035D-4CBC-B468-61D4D62618E7 'iPhone SE clone'
31. $ xcrun simctl boot A08C8834-1547-4EBB-BD3E-06D3732830F7
xcrun simctl boot <device> [-disabledJob=<job>] [-disabledJob=<job>]
xcrun simctl shutdown <device> | all
Booted / Shutdown
$ xcrun simctl shutdown A08C8834-1547-4EBB-BD3E-06D3732830F7
$ xcrun simctl shutdown all
32. $ xcodebuild ~~~ —sdk iphonesimulator
$ xcrun simctl install booted [Build Path]/GiftbotSimulator.app
xcrun simctl install <device> <path>
xcrun simctl uninstall <device> <app identifier>
Uninstall
Install
$ xcrun simctl uninstall booted kr.giftbot.example.GiftbotSimulator
33. $ xcrun simctl launch booted kr.giftbot.example
$ xcrun simctl launch ——console booted kr.giftbot.example
$ xcrun simctl launch booted kr.giftbot.example -AppleLocale "en_US"
-AppleLanguages "(ko)" -NSShowNonLocalizedStrings YES
$ xcrun simctl launch booted kr.giftbot.example -foo "['1', '2']" bar
xcrun simctl launch [-w | ——wait—for—debugger] [——console] [——stdout=<path>]
[——stderr=<path>] <device> <app identifier> [<argv 1> … <argv n>]
xcrun simctl terminate <device> <app identifier>
$ xcrun simctl terminate booted kr.giftbot.example
34. $ xcrun simctl erase A08C8834-1547-4EBB-BD3E-06D3732830F7
$ xcrun simctl erase all
// Unable to erase in Booted state
$ xcrun simctl shutdown <device> && xcrun simctl erase <device>
xcrun simctl erase <device> [… <device n>] | all
erase
35. screenshot [--type=<type>] [--display=<display>] <file or url>
$ xcrun simctl io booted screenshot ——type=jpeg image.jpeg
$ xcrun simctl io booted screenshot ——display=external image.png
recordVideo [--type=<type>] [--display=<display>] <file or url>
$ xcrun simctl io booted recordVideo ——type="mp4" SwiftKorea.mp4
$ xcrun simctl io 90D0D799-69BA-4800-8682-1533100CDD7B recordVideo sim.mp4
xcrun simctl io <device> <operation> <arguments>
36. $ xcrun simctl keyboard booted ko
$ xcrun simctl keyboard booted ja
xcrun simctl keyboard <device> <language>
Add
37. $ xcrun simctl openurl booted https://google.com/search?q=SwiftKorea
$ xcrun simctl openurl booted https://swiftkorea.github.io/meetup/2
xcrun simctl openurl <device> <URL>
38. xcrun simctl <addmedia | addphoto | addvideo> <device> <path> [… <path>]
$ xcrun simctl addmedia booted ~/image.jpeg
$ xcrun simctl addmedia booted ~/video.mp4 ~/image.png …
$ xcrun simctl addphoto booted ~/Desktop/image.jpeg
$ xcrun simctl addvideo booted ~/movie/video.mp4
addmedia
39. $ xcrun simctl listapps booted
$ xcrun simctl listapps booted | grep '"com.apple.*" = ' | grep -o '".*"'
$ xcrun simctl listapps booted | sed -n '1,/kr.giftbot/!p' | sed -n '1,14p'
xcrun simctl listapps <device>
40. $ xcrun simctl appinfo booted kr.giftbot.example.GiftbotSimulator
xcrun simctl appinfo <device> <bundle identifier>
41. $ xcrun simctl spawn booted log stream
$ xcrun simctl spawn booted log stream --type=activity
--style=json —timeout=1m
$ xcrun simctl spawn booted log stream --predicate 'processID == 50854 and
messageType == info'
$ xcrun simctl spawn booted log stream --predicate "eventMessage contains
'Giftbot' and messageType == debug and eventType == logEvent"
$ xcrun simctl spawn booted log collect
xcrun simctl spawn [-w | --wait-for-debugger] [-s | --standalone] [-a <arch> |
--arch=<arch>] <device> <path to executable> [<argv 1> <argv 2> ... <argv n>]
45. $ xcrun simctl list devices
| sed -n '{ 1,/iOS 10/d; /iPhone 6s/p; }'
46. $ xcrun simctl list devices
| sed -n '{ 1,/iOS 10/d; /iPhone 6s/p; }'
| egrep -o '([A-Z0-9-]*){36}'
47. $ xcrun simctl list devices
| sed -n '{ 1,/iOS 10/d; /iPhone 6s/p; }'
| egrep -o '([A-Z0-9-]*){36}'
| xargs -I udid xcrun simctl boot udid
49. $ xcrun simctl list devices
| grep 'iPhone [8X]'
| awk -F "[()]" '{ print $2 }'
| xargs -I udid xcrun simctl shutdown udid
$ list=(`xcrun simctl list devices
| awk '/iPhone/{ if ($2 > 7 && $2 != "SE") print $(NF-1) }'
| cut -c 2-37`)
$ for udid in $list; do
xcrun simctl shutdown $udid
done
50. $ xcrun simctl list devices
| grep -i 'iphone.*plus'
| tail -n 4
| grep -v Booted
| awk -F "[()]" '{ print $2 }'
| xargs -I udid xcrun simctl erase udid
$ xcrun simctl list devices
| grep Shutdown
| egrep -o '[A-Z0-9-]{36}'
| tail -n 4
| xargs -I udid xcrun simctl erase udid
56. [ Simulator 1 ] - English + Locale(US)
[ Simulator 2 ] - Korean
[ Simulator 3 ] - Japanese
[ Simulator 4 ] - Base + DoubleLocalizedString + RightToLeftWritingDirection
57. [ Simulator 1 ] - English + Locale(US)
[ Simulator 2 ] - Korean
[ Simulator 3 ] - Japanese
[ Simulator 4 ] - Base + DoubleLocalizedString + RightToLeftWritingDirection
$ xcrun simctl launch <device> <bundle id> [<argv 1> ...]
58. [ Simulator 1 ] - English + Locale(US)
[ Simulator 2 ] - Korean
[ Simulator 3 ] - Japanese
[ Simulator 4 ] - Base + DoubleLocalizedString + RightToLeftWritingDirection
$ xcrun simctl launch booted kr.giftbot.example [<argv 1> ...]
[ 1 ] -AppleLanguages "(en)" -AppleLocale "en_US"
[ 2 ] -AppleLanguages "(ko)"
[ 3 ] -AppleLanguages "(ja)"
[ 4 ] -NSDoubleLocalizedString YES -NSForceRightToLeftWritingDirection YES
60. $ xcrun simctl launch booted kr.giftbot.example foo bar -swift true
61. let args = ProcessInfo.processInfo.arguments
for (idx, arg) in args.enumerated() {
print("idx : (idx), argument : (arg)")
}
$ xcrun simctl launch booted kr.giftbot.example foo bar -swift true
62. let args = ProcessInfo.processInfo.arguments
for (idx, arg) in args.enumerated() {
print("idx : (idx), argument : (arg)")
}
$ xcrun simctl launch booted kr.giftbot.example foo bar -swift true
idx : 0, argument : <appPath>/<scheme>
idx : 1, argument : foo
idx : 2, argument : bar
idx : 3, argument : -swift
idx : 4, argument : true
64. -Argument => UserDefaults
let isSwift = UserDefaults.standard.bool(forKey: "swift")
print(isSwift) // true
-arr "( 'Swift', 'Korea', 'Giftbot', 'Simulator Customizing & Testing' )"
-dict "{ 'Swift'='Korea'; '2nd'='Meetup'; 'Hi'='Nice to meet you'; }"
-xml "<dict><key>foo</key><string>bar</string></dict>"
let arrArg = UserDefaults.standard.array(forKey: "arr")
let dictArg = UserDefaults.standard.dictionary(forKey: “dict")
let xmlArg = UserDefaults.standard.object(forKey: "xml")
70. $ xcodebuild
-project [projectPath]
—scheme [scheme]
-sdk iphonesimulator
-configuration [ Debug / Beta / Release ]
$ xcrun simctl install booted
[Build Path]/Build/[Configuration]-iphonesimulator/[App Name].app
$ xcodebuild
-project <project path>
—scheme <scheme>
-sdk iphonesimulator
-configuration < Debug / Beta / Release >
$ xcrun simctl install booted
[Build Path]/Build/<configuration>-iphonesimulator/<app name>.app
71. $ xcodebuild
-project <project path>
—scheme <scheme>
-sdk iphonesimulator
-configuration < Debug / Beta / Release >
$ xcrun simctl install booted
[Build Path]/Build/<configuration>-iphonesimulator/<app name>.app
$ xcrun simctl launch <device> <bundle identifier>