スキーム毎に処理を分けたい時、
例えばテスト実行中にアクセスするURLを分岐したい時に使えます。
スキームを選択してEdit Scheme
Environment Varibles
に適当なKeyとValueをセットする
Viewcontroller.swift
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if Scheme.isTesting() {
print("Testing")
} else {
print("Not Testing")
}
}
}
class Scheme {
static func isTesting() -> Bool {
if ProcessInfo().environment["isTesting"] == nil {
return false
}
return true
}
}