Platform.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2020 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import Foundation
  17. // The supported platforms.
  18. enum Platform: CaseIterable {
  19. case iOS
  20. case macOS
  21. case tvOS
  22. var platformTargets: [TargetPlatform] {
  23. switch self {
  24. case .iOS: return [.iOSDevice, .iOSSimulator] + (SkipCatalyst.skip ? [] : [.catalyst])
  25. case .macOS: return [.macOS]
  26. case .tvOS: return [.tvOSDevice, .tvOSSimulator]
  27. }
  28. }
  29. /// Name of the platform as used in Podfiles.
  30. var name: String {
  31. switch self {
  32. case .iOS: return "ios"
  33. case .macOS: return "macos"
  34. case .tvOS: return "tvos"
  35. }
  36. }
  37. /// Minimum supported version
  38. var minimumVersion: String {
  39. switch self {
  40. case .iOS: return PlatformMinimum.minimumIOSVersion
  41. case .macOS: return PlatformMinimum.minimumMacOSVersion
  42. case .tvOS: return PlatformMinimum.minimumTVOSVersion
  43. }
  44. }
  45. }
  46. class PlatformMinimum {
  47. fileprivate static var minimumIOSVersion = ""
  48. fileprivate static var minimumMacOSVersion = ""
  49. fileprivate static var minimumTVOSVersion = ""
  50. static func initialize(ios: String, macos: String, tvos: String) {
  51. minimumIOSVersion = ios
  52. minimumMacOSVersion = macos
  53. minimumTVOSVersion = tvos
  54. }
  55. }
  56. class SkipCatalyst {
  57. fileprivate static var skip = false
  58. static func set() {
  59. skip = true
  60. }
  61. }