Tweak

public protocol Tweak

A type representing an Orion tweak.

A module should contain zero or one types conforming to this protocol. If there are zero, Orion will use DefaultTweak.

Tweaks will default to the backend specified via the Orion CLI. In order to override the backend programmatically, conform to TweakWithBackend instead.

  • The tweak’s initializer and entry point.

    Use this method to perform any custom initialization behavior before DefaultGroup is activated. To perform initialization behavior after DefaultGroup is activated, implement tweakDidActivate() instead.

    Warning

    This method is called at launch time, even before main has been invoked. Do not synchronously perform any time-consuming tasks here, because they will make the target process launch slowly.

    Declaration

    Swift

    init()
  • tweakDidActivate() Default implementation

    Called after all of the tweak’s hooks that are in DefaultGroup have been activated. The default implementation does nothing.

    Default Implementation

    Declaration

    Swift

    func tweakDidActivate()
  • handleError(_:) Default implementation

    Handles errors that occur during hooking.

    The default implementation simply forwards to handleErrorDefault(_:), which logs and terminates the process. If you implement this method yourself, however, you can choose to not terminate the process.

    This method may be called even before Tweak.init() is called.

    Default Implementation

    Declaration

    Swift

    static func handleError(_ error: OrionHookError)

    Parameters

    error

    The error that occurred.

  • handleErrorDefault(_:) Extension method

    The default implementation of handleError(_:).

    This method forwards to orionError(_:file:line:), thereby logging the error and terminating the app with fatalError.

    If you implement handleError(_:) yourself, you may call this method at the end of your implementation.

    Declaration

    Swift

    public static func handleErrorDefault(_ error: OrionHookError) -> Never

    Parameters

    error

    The error that occurred.