[Swift] For development - Switching the code each running machine - コードを実行するPCごとに切り替える

Updated
Mar 13, 2020 10:34 AM
Created
Mar 13, 2020 10:25 AM
Tags
Swift
Keywords
Date

if isInDevelopment([.username("muukii")]) {
  // Run development code to develop
} else {
  // Run stable code
}

#if DEBUG

@inline(__always)
func isInDevelopment(_ conditions: [DebugFilterOption]) -> Bool {
  for condition in conditions {
    switch condition {
    case .username(let username):
      if #file.description.contains(username) {
        return true
      }
    }
  }
  return false
}

#else

@inline(__always)
func isInDevelopment(_ conditions: [DebugFilterOption]) -> Bool {
  return false
}

#endif