I'm working on a Xcode project with Objective C that has optional frameworks which means that some code is executed from that particular framework only if it is linked/exists in project. The current framework that I'm using is PassKit. How can I achieve this? Is there some macro that can tell is framework linked or it is not? Something like this, but it doesn't work:
#if __has_include("PassKit.h") && __has_include(<PassKit.h>)
#import <PassKit/PassKit.h>
#endif
- (void)viewDidAppear:(BOOL)animated {
if ([PKPassLibrary class]) {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"PassKit Test"
message:@"PassKit is linked."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okButton = [UIAlertAction
actionWithTitle:@"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
NSLog(@"Ok pressed...");
}];
[alert addAction:okButton];
[self presentViewController:alert animated:YES completion:nil];
}}
Also I have set Link Frameworks Automatically to NO in my target. Thanks for your answers and help.