# xCode and iOS Simulator tricks ## iOS-Deploy ##### List Bundle IDs on real iOS device `ios-deploy -B` ##### Command line deploy app over USB `ios-deploy -W -b foobar.app` ##### Install, run and debug iOS app on real device from command line `ios-deploy -d -W -b /Debug-iphoneos/tinyDormant.app` ## Build Scripts ##### Better Scripts http://www.mokacoding.com/blog/better-build-phase-scripts/ ##### Add warnings and errors https://briksoftware.com/blog/archives/120/ ## Xcode Behaviors This [SO post](https://stackoverflow.com/questions/7115283/how-to-show-xcode-debugger-in-a-window-separate-from-xcode) shows how to get XCode's debug console as a new Window instead of a small debug Tab. ## Xcodebuild ##### List `xcodebuild -list` ##### Build `xcodebuild -scheme "tinyScheme" -project tiny.xcodeproj` ## Xcode environment variables Read all environment variables available to Xcode: https://gist.github.com/gdavis/6670468 Or print it locally: ``` xcodebuild -project foobar.xcodeproj -target "foobar" -showBuildSettings ``` ### Environment variables I moved away Build Scripts away from: ``` PROJECT_NAME TARGETNAME CURRENT_ARCH ``` As Xcode build tended to use the `PRODUCT_NAME` and `ARCHS` to get the correct env variable. ### Print UUID of Simulator ``` xcrun simctl list | egrep '(Booted)' iPhone 8 (89ECF974-0740-4FBE-8388-BB25AC5503A3) (Booted) Phone: iPhone 8 (89ECF974-0740-4FBE-8388-BB25AC5503A3) (Booted) ``` ### Launch app on Simulator `xcrun simctl launch booted ` ### Terminate app on Simulator `xcrun simctl terminate booted ` ### Inspect KeyChain on Simulator ``` /Users/.../Library/Developer/CoreSimulator/Devices/89ECF974-0740-4FBE-8388-BB25AC5503A3/data/Library/Keychains ``` ### Inspect persisted local files ``` /Users/.../Library/Developer/CoreSimulator/Devices//data/Containers/Data/Application//Documents ``` ### Add Certificate Authority files to Simulators You can drag and drop `.crt` or `.der` certificate files to a simulator in xCode. The iOS Simulator will auto open `Springboard` (Settings) and ask for confirmation of trust. This is a great way to test `UIWebView` or `WKWebView` code with a self-signed certificate chain. Remember, you need to trust the Root CA and Int CA of a `certificate chain`. I never load my leaf certificate.