MFSideMenu is not working in iOS?

415 views Asked by At

Hi i have followed this github page to add MFSideMenu and its showing following error.

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_MFSideMenuContainerViewController", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is my AppDelegate

- (ViewController *)demoController {
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
    ViewController *main = (ViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"home"];

    return  main;
}

- (UINavigationController *)navigationController {
    return [[UINavigationController alloc]
            initWithRootViewController:[self demoController]];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    leftMenuController *leftMenuViewController = [[leftMenuController alloc] init];

    MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
                                                    containerWithCenterViewController:[self navigationController]
                                                    leftMenuViewController:leftMenuViewController
                                                    rightMenuViewController:nil];
    self.window.rootViewController = container;
    [self.window makeKeyAndVisible];
    return YES;
}

enter image description here

2

There are 2 answers

0
Sabby On

Use this code in AppDelegate.m it works for me in storyboard.

- (ViewController *)demoController {
    return [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
}

- (UINavigationController *)navigationController {
    return [[UINavigationController alloc]
            initWithRootViewController:[self demoController]];
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
    MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)self.window.rootViewController;
    UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"navigationController"];
    UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
     UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:@"second" bundle:[NSBundle mainBundle]];
    UIViewController *left = [storyboard1 instantiateViewControllerWithIdentifier:@"rightSideMenuViewController"];

    [container setLeftMenuViewController:leftSideMenuViewController];
    [container setLeftMenuViewController:left];
    [container setCenterViewController:navigationController];

    // Override point for customization after application launch.
    return YES;
}

also take a new view controller in storyboard and mark it as initial view controller and give its class name as well as storyboard id as MFSideMenuContainerViewController.

0
Chatar Veer Suthar On

In general, this will occur when the code for BoxView is not being compiled into your target correctly.

enter image description here

You need to ensure that the target you're building has its corresponding box checked for your MFSideMenuContainerViewController.m implementation file.

A 'Clean and Build' never hurts, either.