Search code examples
iosobjective-cuimotioneffect

No visible @interface for 'UIInterpolatingMotionEffect' declares the selector 'initWithKeyPath:type:'


I am having and issue with UIInterpolatingMotionEffect class, the app compiles but when I try to archive I got this compilation error:

No visible @interface for 'UIInterpolatingMotionEffect' declares the selector 'initWithKeyPath:type:'

I got this error on the initialisers of UIInterpolatingMotionEffect on this function:

- (void)addMotionEffects
{
    UIInterpolatingMotionEffect *horizontalMotionEffect = [[UIInterpolatingMotionEffect alloc]
                                                           initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];

    horizontalMotionEffect.minimumRelativeValue = @(-20);
    horizontalMotionEffect.maximumRelativeValue = @(20);

    UIInterpolatingMotionEffect *verticalMotionEffect = [[UIInterpolatingMotionEffect alloc]
                                                         initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
    verticalMotionEffect.minimumRelativeValue = @(-20);
    verticalMotionEffect.maximumRelativeValue = @(20);

    UIMotionEffectGroup *group = [UIMotionEffectGroup new];
    group.motionEffects = @[horizontalMotionEffect, verticalMotionEffect];
    [self.containerView addMotionEffect:group];
}

I think is a kind of error when trying to compile for arm64 architectures, but I can not figure it out how to solve the problem.

Any ideas?


Solution

  • This is a WTF answer as well as it was a WTF question, but works...

    To avoid the compilation error I have created a category for UIInterpolatingMotionEffect with the selector that give the error. But still don't know why Xcode do not archive without this...

    @interface UIInterpolatingMotionEffect (lol)
    - (instancetype)initWithKeyPath:(NSString *)keyPath type:(UIInterpolatingMotionEffectType)type;
    @end