Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot find protocol declaration for 'CAAnimationDelegate'

My code was fine before, but it tips me :

cannot find protocol declaration for 'CAAnimationDelegate';did you mean 'UIApplicationDelegate'?

when I run it today.

I have tried import QuartzCore/CAAnimation.h but doesn't work.

like image 897
Kayle Best Avatar asked Aug 16 '16 10:08

Kayle Best


1 Answers

CAAnimationDelegate is a new protocol that was added in the iOS 10 SDK. That means it is there if you build with Xcode 8, but not there if you build with Xcode 7.

When you build with Xcode 8, you'll get a warning to say:

Assigning to 'id<CAAnimationDelegate> _Nullable' from incompatible type 'WhateverUIViewController *const __strong'

If you add the CAAnimationDelegate, your code won't build in Xcode 7 anymore. If you need to build with both Xcode's, you need to use ifdefs:

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 100000
// CAAnimationDelegate is not available before iOS 10 SDK
@interface WhateverUIViewController ()
#else
@interface WhateverUIViewController () <CAAnimationDelegate>
#endif
like image 74
JosephH Avatar answered Oct 02 '22 05:10

JosephH