SwiftUIでプレビューできるデバイスの一覧

## 目的
SwiftUIでは開発中の画面が実際にどう表示されるのかをプレビューする機能があります。<br>
その際、プレビューすることができる端末を指定することができますが、デフォルトだとrawValueで指定する方法しかなく、プレビューしたい端末が見つからない&タイポの温床などの問題があるため、端末のリストを作成しました。

## 環境
- Xcode12
- Swift5

## リスト
```Swift
enum DeviceList: String {
    case iPhone_4s = "iPhone 4s"
    case iPhone_5 = "iPhone 5"
    case iPhone_5s = "iPhone 5s"
    case iPhone_6_Plus = "iPhone 6 Plus"
    case iPhone_6 = "iPhone 6"
    case iPhone_6s = "iPhone 6s"
    case iPhone_6s_Plus = "iPhone 6s Plus"
    case iPhone_SE_1st_generation = "iPhone SE (1st generation)"
    case iPhone_7 = "iPhone 7"
    case iPhone_7_Plus = "iPhone 7 Plus"
    case iPhone_8 = "iPhone 8"
    case iPhone_8_Plus = "iPhone 8 Plus"
    case iPhone_X = "iPhone X"
    case iPhone_Xs = "iPhone Xs"
    case iPhone_Xs_Max = "iPhone Xs Max"
    case iPhone_Xʀ = "iPhone Xʀ"
    case iPhone_11 = "iPhone 11"
    case iPhone_11_Pro = "iPhone 11 Pro"
    case iPhone_11_Pro_Max = "iPhone 11 Pro Max"
    case iPhone_SE_2nd_generation = "iPhone SE (2nd generation)"
    case iPod_touch_7th_generation = "iPod touch (7th generation)"
    case iPad_2 = "iPad 2"
    case iPad_Retina = "iPad Retina"
    case iPad_Air = "iPad Air"
    case iPad_mini_2 = "iPad mini 2"
    case iPad_mini_3 = "iPad mini 3"
    case iPad_mini_4 = "iPad mini 4"
    case iPad_Air_2 = "iPad Air 2"
    case iPad_Pro_9_7inch = "iPad Pro (9.7-inch)"
    case iPad_Pro_12_9inch_1st_generation = "iPad Pro (12.9-inch) (1st generation)"
    case iPad_5th_generation = "iPad (5th generation)"
    case iPad_Pro_12_9inch_2nd_generation = "iPad Pro (12.9-inch) (2nd generation)"
    case iPad_Pro_10_5inch = "iPad Pro (10.5-inch)"
    case iPad_6th_generation = "iPad (6th generation)"
    case iPad_7th_generation = "iPad (7th generation)"
    case iPad_Pro_11inch_1st_generation = "iPad Pro (11-inch) (1st generation)"
    case iPad_Pro_12_9inch_3rd_generation = "iPad Pro (12.9-inch) (3rd generation)"
    case iPad_Pro_11inch_2nd_generation = "iPad Pro (11-inch) (2nd generation)"
    case iPad_Pro_12_9inch_4th_generation = "iPad Pro (12.9-inch) (4th generation)"
    case iPad_mini_5th_generation = "iPad mini (5th generation)"
    case iPad_Air_3rd_generation = "iPad Air (3rd generation)"
    case iPad_8th_generation = "iPad (8th generation)"
    case iPad_Air_4th_generation = "iPad Air (4th generation)"
    case Apple_TV = "Apple TV"
    case Apple_TV_4K = "Apple TV 4K"
    case Apple_TV_4K_at_1080p = "Apple TV 4K (at 1080p)"
    case Apple_Watch__38mm = "Apple Watch - 38mm"
    case Apple_Watch__42mm = "Apple Watch - 42mm"
    case Apple_Watch_Series_2__38mm = "Apple Watch Series 2 - 38mm"
    case Apple_Watch_Series_2__42mm = "Apple Watch Series 2 - 42mm"
    case Apple_Watch_Series_3__38mm = "Apple Watch Series 3 - 38mm"
    case Apple_Watch_Series_3__42mm = "Apple Watch Series 3 - 42mm"
    case Apple_Watch_Series_4__40mm = "Apple Watch Series 4 - 40mm"
    case Apple_Watch_Series_4__44mm = "Apple Watch Series 4 - 44mm"
    case Apple_Watch_Series_5__40mm = "Apple Watch Series 5 - 40mm"
    case Apple_Watch_Series_5__44mm = "Apple Watch Series 5 - 44mm"
    case Apple_Watch_SE__40mm = "Apple Watch SE - 40mm"
    case Apple_Watch_SE__44mm = "Apple Watch SE - 44mm"
    case Apple_Watch_Series_6__40mm = "Apple Watch Series 6 - 40mm"
    case Apple_Watch_Series_6__44mm = "Apple Watch Series 6 - 44mm"
}
```

## 情報取得元
[公式ドキュメント](https://developer.apple.com/documentation/swiftui/securefield/previewdevice(_:))に寄れば、下記のコマンドでプレビューできる端末のリストを取得することができます。
```$ xcrun simctl list devicetypes```

取得したdeviceのリストを下記の方法で加工し、上記のリストを作成しました。正規表現など初心者なのでお見苦しいですが...
```$ xcrun simctl list devicetypes | grep -v "Device Types" | sed -e "s/\((\)\(com\.apple\.CoreSimulator\.SimDeviceType\.*\)\([0-9a-zA-Z\-]*\)\()$\)//g"```

```Swift
import Foundation
var rawText = """ //上記コマンドの結果
iPhone 4s
iPhone 5
iPhone 5s
iPhone 6 Plus
iPhone 6
iPhone 6s
iPhone 6s Plus
iPhone SE (1st generation)
iPhone 7
...
"""
    .components(separatedBy: "\n")
var body = "enum DeviceList: String {\n"
rawText.forEach {
    let rawDevice = $0
        .components(separatedBy: " ")
        .map { $0.replacingOccurrences(of: "-", with: "") }
        .map { $0.replacingOccurrences(of: "(", with: "") }
        .map { $0.replacingOccurrences(of: ")", with: "") }
        .map { $0.replacingOccurrences(of: ".", with: "_") }
        .joined(separator: "_")    
    body.append("    case \(rawDevice) = \"\($0)\"\n")
}
body.append("}")
print(body)
```

## 参考
* [SwiftUIのプレビューデバイスを設定する方法](https://qiita.com/Michimae/items/87512856bf63ea0fbe65)
* [Apple Developer - previewDevice(_:)](https://developer.apple.com/documentation/swiftui/securefield/previewdevice(_:))