Configure Static Libraries

I created an Xcode project that contains 2 goals and a static library that I implement for both purposes. Some classes in my static library should be slightly different depending on the compilation of the target.

I do not know how to do that. Any idea?

thanks

+4
source share
1 answer

How should they be different? (I base my answer on the assumption that it can be processed by setting some kind of state variable in classes or a custom init method)

I would suggest you create some form of custom initialization methods or instance variables that you specify for classes that must have different types of behavior. Then you can use custom settings in the build settings for each target.

Check this question and answer for more information: iphone: get User Defined variable in Target setting by code?

Basically you can have a parameter that will be the same line: "Standard", you extract it from

FooBarClass.h typedef enum { FooBarSettingNormal, FooBarSettingFast } FooBarSetting; -(id)initWithSetting:(FooBarSetting)setting; 

And then select the set variable in buildsetting from the code and run the FooBar object as follows:

 SomeViewController.m NSNumber* fooBarSetting = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"FooBarSetting"]; FooBar * baz = [[FooBar alloc] initWithSetting:[fooBarSetting intValue]]; 

This allows you to distinguish between the behavior in your classes and keep the static library separate and autonomous from the project you are using.

Hope you find this somewhat useful :)

0
source

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


All Articles