From 3c0995b5fac97cc4b258f3de1825273e142a016c Mon Sep 17 00:00:00 2001 From: naturecodevoid <44983869+naturecodevoid@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:40:35 -0700 Subject: [PATCH] improve: lock more things behind UNSTABLE compile time flag --- AltStore/Unstable Features/UnstableFeatures.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/AltStore/Unstable Features/UnstableFeatures.swift b/AltStore/Unstable Features/UnstableFeatures.swift index 480cabc3..f653c730 100644 --- a/AltStore/Unstable Features/UnstableFeatures.swift +++ b/AltStore/Unstable Features/UnstableFeatures.swift @@ -9,16 +9,21 @@ import Foundation class UnstableFeatures { + #if UNSTABLE fileprivate struct Metadata { + /// If true, this Unstable Feature will be available in Advanced Settings instead of being exclusive to Developer Mode. var availableOutsideDevMode = false + /// Run when the feature is enabled. var onEnable = {} + /// Run when the feature is disabled var onDisable = {} } + #endif enum Feature: String, CaseIterable { // The value will be the GitHub Issue number. For example, "123" would correspond to https://github.com/SideStore/SideStore/issues/123 // - // Unstable features must have a GitHub Issue for tracking progress, PRs and feedback/bug reporting/commenting. + // Unstable Features must have a GitHub Issue for tracking progress, PRs and feedback/bug reporting/commenting. // // Please order the case by the issue number. They will be ordered by issue number (ascending) in the unstable features menu, so please order them the same way here and in `metadata`. @@ -29,12 +34,14 @@ class UnstableFeatures { /// Dummy variant to ensure there is always at least one variant. DO NOT USE! case dummy = "dummy" + #if UNSTABLE fileprivate var metadata: Metadata { switch self { // If your unstable feature is stable enough to be used by nightly users who are not alpha testers or developers, // you may want to have it available in the Unstable Features menu in Advanced Settings (outside of dev mode). To do so, add this: //case .yourFeature: return Metadata(availableOutsideDevMode: true) // You can also add custom hooks for when your feature is enabled or disabled. However, we strongly recommend moving these to a new file. Example: https://github.com/SideStore/SideStore/blob/026392dbc7a5454a39b9287f469d32b5e6768bb8/AltStore/Unstable%20Features/UnstableFeatures%2BSwiftUI.swift + // See the `Metadata` struct for more things you can do. // Please keep the ordering of the cases in this switch statement the same as the ordering of the enum variants! case .swiftUI: return Metadata(availableOutsideDevMode: true, onEnable: SwiftUI.onEnable, onDisable: SwiftUI.onDisable) @@ -43,6 +50,7 @@ class UnstableFeatures { default: return Metadata() } } + #endif } #if UNSTABLE