Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS App modularization at build time

I have my app's home screen as the following prototype : enter image description here Considering this home screen, I have to develop the app in such a way that every feature among these four should be pluggable at build time. For example,

If I set a macro like

#define FEATURE_1  0

then, the home screen will have only 3 tiles for the remaining three features. Also, the files that are related to feature-1 should not get compiled in the resulting .ipa .

When i was developing these four modules, I have kept all the classes independent of each other. But the problem is I have a single storyboard which contains the whole UI. Now, I have to separate the UI and resources in such a way that if any of features is turned off, no files related to that feature should get compiled.

What i have tried : I read somewhere that making each feature as a static library would get my job done, however, I couldn't figure out how would I include/exclude a static library at build time. Also, it doesn't solve my problem of separating the views in the storyboard.

Specifically, the questions I have are :

1) How can I copy specific files to my project and leave out specific files depending upon the macro as a defined above? If it is possible, please direct me towards a good way of doing it.

2) How can I separate out the views on storyboard? May be define multiple storyboards and include the required ones at build time? Please guide.

like image 995
Sagar D Avatar asked Oct 14 '15 15:10

Sagar D


2 Answers

Answer for 1 : You can't using only macros.

Create several targets for your different configurations, defines the macros you need on each target and toggle the file include checkbox to only include the needed files during the build.

like image 70
Moose Avatar answered Oct 19 '22 16:10

Moose


Although you could use the build system, in your case it seems easier to you wrap the affected code in

#if FEATURE_1
...
#endif

For hiding the views you could use code in line of

#if !FEATURE_1
    feature1View.hidden = YES;
#endif

depending what exactly you are trying to achieve.

like image 30
eik Avatar answered Oct 19 '22 17:10

eik