# Xcode Snippets

## CLI Build

```bash
xcodebuild -list -project Project.xcodeproj
xcodebuild -scheme iOS build
```

## CLI Test

```bash
xcodebuild test -project Project.xcodeproj -scheme Tests -destination 'platform=iOS Simulator,name=iPad Air 2,OS=10.0'
```

## CLI xcrun

```bash
xcrun -sdk iphoneos swiftc -target armv7-apple-ios10.0 main.swift
```

## Trouble Shooting

```bash
# clean == ⌘ + ⌥ + k
# full clean == ⌘ + ⌥ + ⇧ + k
```

## Switch Xcode Install

```bash
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
```

## Add new-iOS Support to legacy Xcode

```bash
# hella unsupported
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/11.0\ \(15A372\) /Applications/Xcode8.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/11.0
```

## Playgrounds

```bash
# Inserting the following into a playground simulates a playholder and will cause the playground to exit to the simulator it's containing:

override public func viewDidAppear(_ animated: Bool) {
    <#code#>
}
```

```swift
import PlaygroundSupport
...
PlaygroundPage.current.liveView = viewController.view
...
PlaygroundPage.current.needsIndefiniteExecution

```

## Simulator

```bash
xcrun simctl list | grep Air
xcrun simctl boot "iPad Air 2"
xcrun simctl install booted Project.swiftmodule
```

## Devices

```bash
instruments -s devices
```
