Platform.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. enum 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. /// Useful to disable minimum version checking on pod installation. Pods still get built with
  56. /// for the minimum version specified in the podspec.
  57. static func useRecentVersions() {
  58. minimumIOSVersion = "14.0"
  59. minimumMacOSVersion = "11.0"
  60. minimumTVOSVersion = "14.0"
  61. }
  62. }
  63. enum SkipCatalyst {
  64. fileprivate static var skip = false
  65. static func set() {
  66. skip = true
  67. }
  68. }