I am trying to add conditional code to prevent "Symbol not found" errors on an iOS 7 device when using an iOS 8 class, in this case UIBlurEffect
:
dyld: Symbol not found: _OBJC_CLASS_$_UIBlurEffect
Even though the code within the conditional does not run (I do not see the "UIBlurEffect will be used!" log statement), I still get the error. If I comment the block out, it runs fine.
BOOL blurAvailable = NSClassFromString(@"UIBlurEffect") ? YES : NO;
if (blurAvailable)
NSLog(@"UIBlurEffect available");
else
NSLog(@"UIBlurEffect not available");
if (navBarBlurBool && blurAvailable)
{
NSLog(@"UIBlurEffect will be used!");
if (![viewController.navigationController.navigationBar viewWithTag:BLUR_NAVBAR_TAG])
{
// Code works on iOS 7 if this block is commented out:
[self storeOriginalNavBarImages];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
blur.frame = CGRectMake(0, -1 * statusBarFrame.size.height, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height + statusBarFrame.size.height);
blur.userInteractionEnabled = NO;
blur.tag = BLUR_NAVBAR_TAG;
[self.navigationController.navigationBar insertSubview:blur atIndex:0];
}
}
I don't understand - I would assume that if blurAvailable
is false then the offending code should not run and I should not get the "Symbol not found" runtime error.
I'm using iOS 9.2 SDK. Xcode 7.2. Deployment target is iOS 7.0.