mirror of
https://github.com/xtool-org/xtool.git
synced 2026-02-09 20:38:47 +01:00
34 lines
1.0 KiB
Swift
34 lines
1.0 KiB
Swift
//
|
|
// DeveloperServicesAppIDRequestApplier.swift
|
|
// Supersign
|
|
//
|
|
// Created by Kabir Oberai on 11/10/19.
|
|
// Copyright © 2019 Kabir Oberai. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
enum DeveloperServicesAppIDRequestApplier {
|
|
|
|
static func apply(
|
|
entitlements: Entitlements, additionalFeatures: [DeveloperServicesFeature],
|
|
to dict: inout [String: Any], isFree: Bool
|
|
) {
|
|
var entitlements = entitlements
|
|
try? entitlements.updateEntitlements {
|
|
$0.removeAll {
|
|
let type = Swift.type(of: $0)
|
|
return !type.canList || (isFree && !type.isFree)
|
|
}
|
|
}
|
|
dict["entitlements"] = try? entitlements.plistValue()
|
|
|
|
let entFeatures = (try? entitlements.entitlements().compactMap { $0.feature() }) ?? []
|
|
let allFeatures = entFeatures + additionalFeatures
|
|
guard let features = try? DeveloperServicesFeatures(values: allFeatures).plistValue() as? [String: Any]
|
|
else { return }
|
|
dict.merge(features) { a, _ in a }
|
|
}
|
|
|
|
}
|