6

I am building an iOS framework and i need the same framework to be used in public apps and in some internal apps , the difference is that in the internal apps I need access to some classes and function that I want to hide from the public apps and i don't want to copy paste code from the framework to the internal apps ...

Is it possible to use conditional compilation (or some other solution without duplicating code) to do something like :

#if SOMEFLAG
   public
#else
   internal
#endif
   class SomeClass{
       // public when SOMEFLAG otherwise internal
   }

of course the code above is not working so it is the pseudo code for what i need ( it doesn't have to be with macros) .

Thanks.

Oleg Sherman
  • 2,772
  • 1
  • 21
  • 20
  • Possible duplicate of [#ifdef replacement in swift language](http://stackoverflow.com/questions/24003291/ifdef-replacement-in-swift-language) – Sweeper Nov 10 '16 at 07:46
  • @Sweeper the link doesn't work for access control, my question is about conditional access control without duplicating code , it doesn't have to be with macros. – Oleg Sherman Nov 10 '16 at 07:47
  • It is not possible to define in that way, Swift Compiler will through the error. How are you planning to distribute the framework. – Sachin Vas Nov 10 '16 at 09:00
  • I will give the clients the .framework file directly, i don't want to give them the source code. – Oleg Sherman Nov 10 '16 at 09:36
  • @OlegSherman did you get any solution? – amar Apr 21 '17 at 04:31
  • @amar I did not get a solution yet. – Oleg Sherman Apr 21 '17 at 05:50
  • @OlegSherman i am starting to read this https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/cross_development/Using/using.html will let you know if i get a solution.If you get it earlier do let me know – amar Apr 21 '17 at 06:16

0 Answers0