广泛的想法和实施想法在这里:https://www.craft.do/s/VIzO95A9chLeoW
测试应用程序在这里:https://github.com/codeOfRobin/TestingCloudKitFeatureFlags (需要设置 CloudKit 容器并使用您的 开发者帐户更改签名功能)
通过 Swift Package Manager 添加到您的项目,包 URL:https://github.com/codeOfRobin/CloudKitFeatureFlags
。由于我们仍处于早期阶段,建议使用 main
分支。
CloudKitFeatureFlagsRepository
的一个实例let container = CKContainer(identifier: "your container goes here, please make sure it's correctly set up in the "Signing and Capabilities section in Xcode")
lazy var featureFlags = CloudKitFeatureFlagsRepository(container: container)
/// For Combine reasons
var cancellables = Set<AnyCancellable>()
featureFlagsRepository
查询特性标志的状态。在未来(即将推出!) 它将通过 CKSubscription
实时更新featureFlags.featureEnabled(name: "some_feature_flag").sink(receiveCompletion: { (_) in }) { (value) in
/// use `value` to change your UI imperatively, or bind the publisher directly!
print(value)
}.store(in: &cancellables)