Capable

public struct Capable

This class defines the main interface of the Capable framework.

  • Initializes the framework instance with a specified set of features. If no feature was provided, this defaults to all features available on the current platform.

    Declaration

    Swift

    public init(withFeatures features: [CapableFeature] = CapableFeature.allCases)

    Parameters

    features

    An optional array containing the features of interest. This will default to all features available on the current platform.

  • Initializes the framework instance with a set of Handicaps.

    • handicaps: An optional array containing the Handicapss specified by the caller.

    Declaration

    Swift

    public init(withHandicaps handicaps: [Handicap])
  • The statusMap property returns a dictionary of all CapableFeatures or Handicaps , that the Capable instance has been initialized with along with their current statuses. This object is compatible with most analytic SDKs such as Fabric Answers, Firebase Analytics, AppCenter Analytics, or HockeyApp. While most entries can only have a status set to enabled or disabled, the .largerText feature offers the font scale set by the user.

    Declaration

    Swift

    public var statusMap: [String : String] { get }
  • Provides information regarding the current status of a provided feature.

    Declaration

    Swift

    public func isFeatureEnabled(feature: CapableFeature) -> Bool

    Parameters

    feature

    The feature of interest.

    Return Value

    true if the given feature has been enabled, otherwise false.

  • Provides information regarding the current status of a provided Handicap.

    • handicapName: The name of the requested of Handicap.

    Declaration

    Swift

    public func isHandicapEnabled(handicapName: String) -> Bool

    Return Value

    true if the given feature has been enabled, otherwise false. Note that the status depends on the Handicap‘s enabledIf value (see HandicapEnabledMode).

  • The minimum log level that should be considered when logging messages. Note that the custom ‘onLog’ closure will only be called for messages of this log type or higher. This value defaults to OSLogType.debug.

    Declaration

    Swift

    public static var minLogType: OSLogType { get set }
  • A custom closure that should be used by the logger for all Capable instances instead of the default os_log implementation.

    • message: The message string that is about to be logged.
    • logType: The ‘OSLogType’ of the message.

    Declaration

    Swift

    public static var onLog: (_ message: String, _ logType: OSLogType) -> Void { get set }