SlideShare a Scribd company logo
1 of 82
Download to read offline
Simulator
Simulator
Tips & Tricks
CLI, simctl
Testing
Demo
Simulator allows you to rapidly prototype and
test builds of your app during the development process.
open -a Simulator
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
open -a Simulator --args -CurrentDeviceUDID $UDID
sudo mkdir /AppleInternal
Allow Fullscreen Mode
Show Chrome UI Rects
$ 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]
xcrun simctl delete <device> [… <device n>] | unavailable
$ xcrun simctl delete 1418D7BD-CD6E-4C8A-AF95-580680AD5B2A
Delete
$ cd /Library/Developer/CoreSimulator/Profiles/Runtimes
$ sudo rm -rf <iOS version>.simruntime
$ xcrun simctl delete unavailable
2.72 GB
$ 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>
$ 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'
$ 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
$ 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
$ 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
$ 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
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>
$ xcrun simctl keyboard booted ko
$ xcrun simctl keyboard booted ja
xcrun simctl keyboard <device> <language>
Add
$ 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>
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
$ 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>
$ xcrun simctl appinfo booted kr.giftbot.example.GiftbotSimulator
xcrun simctl appinfo <device> <bundle identifier>
$ 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>]
bootstatus
darwinup
diagnose
get_app_container
getenv
icloud_sync
logverbose
monitor
notify_post
notify_get_state / notify_set_state
pair / unpair
pair_activate
pbinfo / pbsync
pbcopy / pbpaste
register / unregister
upgrade
$ xcrun simctl list devices
$ xcrun simctl list devices 
| sed -n '{ 1,/iOS 10/d; /iPhone 6s/p; }'
$ xcrun simctl list devices 
| sed -n '{ 1,/iOS 10/d; /iPhone 6s/p; }' 
| egrep -o '([A-Z0-9-]*){36}'
$ 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
$ 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
$ 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
Case 1. Localization
Case 4. Devices
Case 5. Network
Case 2. Arguments
Case 3. Configurations
Shutdown
List
Create / Clone
Boot
[ 1 ]
Shutdown
List
Create / Clone
Boot
Build
Install
Launch
Test
[ 1 ] [ 2 ]
Shutdown
List
Create / Clone
Boot
Build
Install
Launch
Test
Terminate
Shutdown
Erase / Delete
[ 1 ] [ 3 ][ 2 ]
[ Simulator 1 ] - English + Locale(US)
[ Simulator 2 ] - Korean
[ Simulator 3 ] - Japanese
[ Simulator 4 ] - Base + DoubleLocalizedString + RightToLeftWritingDirection
[ Simulator 1 ] - English + Locale(US)
[ Simulator 2 ] - Korean
[ Simulator 3 ] - Japanese
[ Simulator 4 ] - Base + DoubleLocalizedString + RightToLeftWritingDirection
$ xcrun simctl launch <device> <bundle id> [<argv 1> ...]
[ 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
$ xcrun simctl launch booted kr.giftbot.example foo bar -swift true
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
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
-Argument => UserDefaults
let isSwift = UserDefaults.standard.bool(forKey: "swift")
print(isSwift) // true
-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")
$ xcodebuild
-project <project path>
—scheme <scheme>
-sdk iphonesimulator
-configuration < Debug / Beta / Release >
$ 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
$ 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>
xcrun simctl list devices | egrep ~ blah blah ~
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9
Simulator customizing & testing for Xcode 9

More Related Content

What's hot

international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
smueller_sandsmedia
 
C++ Programming - 12th Study
C++ Programming - 12th StudyC++ Programming - 12th Study
C++ Programming - 12th Study
Chris Ohk
 

What's hot (20)

async/await Revisited
async/await Revisitedasync/await Revisited
async/await Revisited
 
Writing Your App Swiftly
Writing Your App SwiftlyWriting Your App Swiftly
Writing Your App Swiftly
 
AST Rewriting Using recast and esprima
AST Rewriting Using recast and esprimaAST Rewriting Using recast and esprima
AST Rewriting Using recast and esprima
 
Workshop 5: JavaScript testing
Workshop 5: JavaScript testingWorkshop 5: JavaScript testing
Workshop 5: JavaScript testing
 
Your code is not a string
Your code is not a stringYour code is not a string
Your code is not a string
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Letswift19-clean-architecture
Letswift19-clean-architectureLetswift19-clean-architecture
Letswift19-clean-architecture
 
Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6
 
PHP 5.4
PHP 5.4PHP 5.4
PHP 5.4
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
Writing Clean Code in Swift
Writing Clean Code in SwiftWriting Clean Code in Swift
Writing Clean Code in Swift
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End Developers
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
 
Capability Driven Design - Andrzej Jóźwiak - TomTom Dev Day 2021
Capability Driven Design - Andrzej Jóźwiak  - TomTom Dev Day 2021Capability Driven Design - Andrzej Jóźwiak  - TomTom Dev Day 2021
Capability Driven Design - Andrzej Jóźwiak - TomTom Dev Day 2021
 
C++ Programming - 12th Study
C++ Programming - 12th StudyC++ Programming - 12th Study
C++ Programming - 12th Study
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
 
C++ Programming - 9th Study
C++ Programming - 9th StudyC++ Programming - 9th Study
C++ Programming - 9th Study
 
Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 

Similar to Simulator customizing & testing for Xcode 9

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 

Similar to Simulator customizing & testing for Xcode 9 (20)

Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 
Workshop on command line tools - day 2
Workshop on command line tools - day 2Workshop on command line tools - day 2
Workshop on command line tools - day 2
 
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
 
Embedded Android
Embedded AndroidEmbedded Android
Embedded Android
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
Clojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMClojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVM
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
Defcon 22-colby-moore-patrick-wardle-synack-drop camDefcon 22-colby-moore-patrick-wardle-synack-drop cam
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
 
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...Visual Component Testing  -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
Visual Component Testing -- w/ Gil Tayar (Applitools) and Gleb Bahmutov (Cyp...
 
Groovy
GroovyGroovy
Groovy
 
Learning Dtrace
Learning DtraceLearning Dtrace
Learning Dtrace
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
From Java To Clojure (English version)
From Java To Clojure (English version)From Java To Clojure (English version)
From Java To Clojure (English version)
 
Really useful linux commands
Really useful linux commandsReally useful linux commands
Really useful linux commands
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
The Gremlin Graph Traversal Language
The Gremlin Graph Traversal LanguageThe Gremlin Graph Traversal Language
The Gremlin Graph Traversal Language
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
 

More from Bongwon Lee (8)

DeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUIDeprecatedAPI로 알아보는 SwiftUI
DeprecatedAPI로 알아보는 SwiftUI
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
App Lifecycle
App LifecycleApp Lifecycle
App Lifecycle
 
GraphQL over REST
GraphQL over RESTGraphQL over REST
GraphQL over REST
 
The Sandbox Container Directory
The Sandbox Container DirectoryThe Sandbox Container Directory
The Sandbox Container Directory
 
LetSwift 2017 - ARKit
LetSwift 2017 - ARKitLetSwift 2017 - ARKit
LetSwift 2017 - ARKit
 
Realm, Mobile Database
Realm, Mobile DatabaseRealm, Mobile Database
Realm, Mobile Database
 
Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)Custom Xcode Template (with VIPER)
Custom Xcode Template (with VIPER)
 

Recently uploaded

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (6)

BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 
Leading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfLeading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdf
 

Simulator customizing & testing for Xcode 9

  • 2. Simulator Tips & Tricks CLI, simctl Testing Demo
  • 3. Simulator allows you to rapidly prototype and test builds of your app during the development process.
  • 4.
  • 5. open -a Simulator open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/ open -a Simulator --args -CurrentDeviceUDID $UDID
  • 6.
  • 7.
  • 8.
  • 9.
  • 12.
  • 13.
  • 14. Show Chrome UI Rects
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 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]
  • 23.
  • 24. xcrun simctl delete <device> [… <device n>] | unavailable $ xcrun simctl delete 1418D7BD-CD6E-4C8A-AF95-580680AD5B2A Delete
  • 25. $ cd /Library/Developer/CoreSimulator/Profiles/Runtimes $ sudo rm -rf <iOS version>.simruntime
  • 26. $ xcrun simctl delete unavailable 2.72 GB
  • 27.
  • 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>
  • 29.
  • 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>]
  • 43.
  • 44. $ xcrun simctl list devices
  • 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
  • 48.
  • 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
  • 51. Case 1. Localization Case 4. Devices Case 5. Network Case 2. Arguments Case 3. Configurations
  • 55.
  • 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
  • 59.
  • 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
  • 63. -Argument => UserDefaults let isSwift = UserDefaults.standard.bool(forKey: "swift") print(isSwift) // 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")
  • 65.
  • 66.
  • 67.
  • 68.
  • 69. $ xcodebuild -project <project path> —scheme <scheme> -sdk iphonesimulator -configuration < Debug / Beta / Release >
  • 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>
  • 72.
  • 73. xcrun simctl list devices | egrep ~ blah blah ~