IPhone compiled according to purpose

I have a project with several goals for several clients, but most applications are very the same, and so far I have been able to control different program flows with lists of properties that are read at runtime.

One client has a certain idea that I need to show in front of everyone else.

My problem is that I get a build error (actually a link error), because since the controller class is not included in other target clients, and I also don't want to include it. So I was looking for some compile time control.

I'm looking for something like

#ifdef client1target
     ... do something
#else
     ... do something else
#endif    

In the part of the program that I encountered, it looks like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    NSString *client = [myEnvVariables getShortName]; // In this class method I read the plist

    if ([client isEqualToString:@"CLIENT1"]) {

        Client1SpecificController *mm = [[Client1SpecificController alloc] initWithNibName:@"Client1SpecificView" bundle:nil];
// here happens the compile error because Client1SpecificController is not known at other targets

        mm.view.frame = CGRectMake(0,20,320,460);

        [window addSubview:mm.view];
        [window makeKeyAndVisible]; 

    } else {

        [window addSubview:navigationController.view];
        [window makeKeyAndVisible]; 
    }

    return YES;
}

The error looks like this:

undefined symbols:
  "_OBJC_CLASS_$_Client1SpecificController", referenced from:
      objc-class-ref-to-Client1SpecificController in myAppDelegate.o
+3
1

" ", -, , CLIENT_ONE

,

#ifdef CLIENT_ONE
    #import "ClassOneController.h"
#else
    #import "OtherController.h"
#endif

: For This Example add CLIENT_ONE = 1

+9

Source: https://habr.com/ru/post/1781037/


All Articles