MimiSDK 3 Migration Guide

This document outlines the various changes required to migrate to MimiSDK 3 from a previous version of MimiSDK.

MimiSDK 3 introduces several API-breaking changes that should be made aware of.

Requirements

  • iOS 11 or above.
  • Xcode 11.
  • Swift 5.

What’s new

  • Support for iOS 13 and Xcode 11.
  • Simpler, more reliable Processor API.
  • Dark Mode support.

Changes

The following section describes all changes that are considered breaking API or significant behavioral changes.


MimiProcessingHandler

There have been numerous changes to make the MimiProcessingHandler simpler and more consistent semantically with other elements of the codebase. The methods that are required to be implemented have been replaced, and other deprecated properties have been removed.

Setting a Parameter

PREVIOUS - MimiSDK 2.x

func apply(value: MimiProcessingParameter.Value, 
           completion: ((Error?) -> Void)?) {
    switch value {
        case .isEnabled(let value):
            // Enable / Disable processing
            completion?(nil)
        default:
            break
    }
}

CURRENT - MimiSDK 3.x

func setParameter(_ parameter: MimiProcessingParameter.Writable, 
                  result: ((MimiProcessingParameter.WriteResult) -> Void)?) {
    switch parameter.value {
        case .isEnabled(let value):
            // Enable / Disable processing
            result?(.success)
        default:
            break
    }
}

Getting a Parameter

PREVIOUS - MimiSDK 2.x

func loadValue(for parameter: MimiProcessingParameter, 
               completion: ((MimiProcessingParameter.Value?, Error?) -> Void)?) {
    switch parameter {
        case .isEnabled:
            // Read whether processing is enabled
            completion?(.isEnabled(true), nil)
        default:
            break
    }
}

CURRENT - MimiSDK 3.x

func getParameter(_ parameter: MimiProcessingParameter.Readable, 
                  result: ((MimiProcessingParameter.ReadResult) -> Void)?) {
    switch parameter {
        case .isEnabled:
            // Read whether processing is enabled
            result?(.success(.isEnabled(true)))
        default:
            break
    }
}

MimiProcessingController

Alongside changes to the MimiProcessingHandler, MimiProcessingController has received significant API changes to clean up semantics.

Setting a Handler Parameter

PREVIOUS - MimiSDK 2.x

let processing = MimiCore.shared.processing
processing.set(value: .isEnabled(sender.isSelected)) { (error) in
    print(error)
}

CURRENT - MimiSDK 3.x

let processing = MimiCore.shared.processing
processing.setParameter(.isEnabled(true)) { (result) in
    switch result {
    case .success:
        print("success")
    case .failure(let error):
        print(error)
    }
}

Getting a Handler Parameter

PREVIOUS - MimiSDK 2.x

let processing = MimiCore.shared.processing
processing.get(parameter: .isEnabled) { (value, error) in
    print(value)
}

CURRENT - MimiSDK 3.x

let processing = MimiCore.shared.processing
processing.getParameter(.isEnabled) { (result) in
    switch result {
    case .success(let value):
        print(value)
    case .failure(let error):
        print(error)
    }
}

Getting Multiple Handler Parameters

PREVIOUS - MimiSDK 2.x

let processing = MimiCore.shared.processing
processing.get(parameters: .isEnabled, .intensity) { (values, error) in
    print(values)
}

CURRENT - MimiSDK 3.x

let processing = MimiCore.shared.processing
processing.getParameters([.isEnabled, .intensity]) { (result) in
    switch result {
    case .success(let values):
        print(values)
    case .failure(let error):
        print(error)
    }
}

MimiProcessingParameterObservable

The parameter observable API has been simplified significantly to make watching changes to Processing Parameters much easier.

The individual functions for successful GET and SET operations have been unified into a single function that will simply provide the latest known value for a processing parameter.

Observing Parameter Updates

PREVIOUS - MimiSDK 2.x

func processingDidGet(value: MimiProcessingParameter.Value, 
                      from handler: MimiProcessingHandler) {
}

func processingDidSet(value: MimiProcessingParameter.Value, 
                      on handler: MimiProcessingHandler) {
}

CURRENT - MimiSDK 3.x

func processingDidUpdate(value: MimiProcessingParameter.Value, 
                         on handler: MimiProcessingHandler) {
}

Note - the individual functions for failure to set and failure to get still exist as before.

Parameter Invalidation

The function that would inform an observable that a parameter has been invalidated in MimiProcessingParameterObservable has been removed - instead replaced with internal behaviour that will automatically fetch any invalidated parameters that can be read.

Invalidating the .preset or .fitting will now force fetching a new preset and delivery to the active Processing Handler.

Removals

  • Removed fittingRule from MimiProcessingHandler.
  • Removed observable from MimiProcessingController.
  • Removed MimiProcessingControllerObservable.
  • Removed load(route:fittingRule:result:) from MimiPersonalizationController.
  • Removed canProcessingBeEnabled from MimiProcessingController.
  • Removed activate(handler:) from MimiProcessingController.
  • Removed invalidate(cause:) from MimiProcessingController.
  • Removed MimiPersonalization.FittingRule.
  • Removed MimiProcessingError.
  • Removed processingDidInvalidate() from MimiProcessingParameterObservable.
  • Removed processingDidGet() from MimiProcessingParameterObservable.
  • Removed processingDidSet() from MimiProcessingParameterObservable.
  • Removed MimiLabel.Style.largeTitle.
  • Removed MimiFontBook.Font.largeTitle.
  • Removed MimiFontBook.largeTitle.
  • Removed MimiCheckbox.checkColor.
  • Removed start(clientId:clientSecret:) from MimiSDK.