InterposeError

public enum InterposeError : LocalizedError
extension InterposeError: Equatable

The list of errors while hooking a method.

  • The method couldn’t be found. Usually happens for when you use stringified selectors that do not exist.

    Declaration

    Swift

    case methodNotFound(AnyClass, Selector)
  • The implementation could not be found. Class must be in a weird state for this to happen.

    Declaration

    Swift

    case nonExistingImplementation(AnyClass, Selector)
  • Someone else changed the implementation; reverting removed this implementation. This is bad, likely someone else also hooked this method. If you are in such a codebase, do not use revert.

    Declaration

    Swift

    case unexpectedImplementation(AnyClass, Selector, IMP?)
  • Unable to register subclass for object-based interposing.

    Declaration

    Swift

    case failedToAllocateClassPair(class: AnyClass, subclassName: String)
  • Unable to add method for object-based interposing.

    Declaration

    Swift

    case unableToAddMethod(AnyClass, Selector)
  • Object-based hooking does not work if an object is using KVO. The KVO mechanism also uses subclasses created at runtime but doesn’t check for additional overrides. Adding a hook eventually crashes the KVO management code so we reject hooking altogether in this case.

    Declaration

    Swift

    case keyValueObservationDetected(AnyObject)
  • Object is lying about it’s actual class metadata. This usually happens when other swizzling libraries (like Aspects) also interfere with a class. While this might just work, it’s not worth risking a crash, so similar to KVO this case is rejected.

    @note Printing classes in Swift uses the class posing mechanism. Use NSClassFromString to get the correct name.

    Declaration

    Swift

    case objectPosingAsDifferentClass(AnyObject, actualClass: AnyClass)
  • Can’t revert or apply if already done so.

    Declaration

    Swift

    case invalidState(expectedState: AnyHook.State)
  • Unable to remove hook.

    Declaration

    Swift

    case resetUnsupported(_: String)
  • Generic failure

    Declaration

    Swift

    case unknownError(_: String)
  • Declaration

    Swift

    public static func == (lhs: InterposeError, rhs: InterposeError) -> Bool
  • Declaration

    Swift

    public var errorDescription: String? { get }