2022-12-08 16:59:51 -08:00
|
|
|
//
|
|
|
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the MIT License (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
|
//
|
|
|
|
|
// ProcessInfo+Extensions.swift
|
|
|
|
|
//
|
|
|
|
|
// Created by Nacho Soto on 11/29/22.
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
2023-05-26 07:18:51 -07:00
|
|
|
#if DEBUG
|
|
|
|
|
|
2022-12-08 16:59:51 -08:00
|
|
|
enum EnvironmentKey: String {
|
|
|
|
|
|
|
|
|
|
case XCTestConfigurationFile = "XCTestConfigurationFilePath"
|
|
|
|
|
case RCRunningTests = "RCRunningTests"
|
|
|
|
|
case RCRunningIntegrationTests = "RCRunningIntegrationTests"
|
2023-05-26 07:18:51 -07:00
|
|
|
case RCMockAdServicesToken = "RCMockAdServicesToken"
|
2023-10-21 11:12:16 -07:00
|
|
|
case XCCloud = "XCODE_CLOUD"
|
2022-12-08 16:59:51 -08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension ProcessInfo {
|
|
|
|
|
|
|
|
|
|
static subscript(key: EnvironmentKey) -> String? {
|
|
|
|
|
return Self.processInfo.environment[key.rawValue]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension ProcessInfo {
|
|
|
|
|
|
|
|
|
|
static var isRunningUnitTests: Bool {
|
|
|
|
|
return self[.XCTestConfigurationFile] != nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// `true` when running unit or integration tests (configured in .xctestplan files).
|
|
|
|
|
static var isRunningRevenueCatTests: Bool {
|
|
|
|
|
return self[.RCRunningTests] == "1"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// `true` when running integration tests (configured in .xctestplan files).
|
|
|
|
|
static var isRunningIntegrationTests: Bool {
|
|
|
|
|
return self[.RCRunningIntegrationTests] == "1"
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-26 07:18:51 -07:00
|
|
|
static var mockAdServicesToken: String? {
|
2023-08-30 06:10:33 -07:00
|
|
|
guard let token = self[.RCMockAdServicesToken], !token.isEmpty else { return nil }
|
|
|
|
|
|
|
|
|
|
return token
|
2023-05-26 07:18:51 -07:00
|
|
|
}
|
|
|
|
|
|
2023-10-21 11:12:16 -07:00
|
|
|
static var isXcodeCloud: Bool {
|
|
|
|
|
return self[.XCCloud] == "1"
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 16:59:51 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|