forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlusFeatureFlag.swift
More file actions
45 lines (35 loc) · 1.01 KB
/
PlusFeatureFlag.swift
File metadata and controls
45 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import Foundation
import SwiftUI
#if canImport(LicenseManagement)
import LicenseManagement
#else
public typealias PlusFeatureFlag = Int
@dynamicMemberLookup
public struct PlusFeatureFlags {
public subscript(dynamicMember dynamicMember: String) -> PlusFeatureFlag { return 0 }
init() {}
}
#endif
public func withFeatureEnabled(
_ flag: KeyPath<PlusFeatureFlags, PlusFeatureFlag>,
then: () throws -> Void
) rethrows {
#if canImport(LicenseManagement)
try LicenseManagement.withFeatureEnabled(flag, then: then)
#endif
}
public func withFeatureEnabled(
_ flag: KeyPath<PlusFeatureFlags, PlusFeatureFlag>,
then: () async throws -> Void
) async rethrows {
#if canImport(LicenseManagement)
try await LicenseManagement.withFeatureEnabled(flag, then: then)
#endif
}
public func isFeatureAvailable(_ flag: KeyPath<PlusFeatureFlags, PlusFeatureFlag>) -> Bool {
#if canImport(LicenseManagement)
return LicenseManagement.isFeatureAvailable(flag)
#else
return false
#endif
}