I'm currently working on a project that has a class referencing the Security.h framework. Since this is a reusable class, and might be used in multiple projects, I wish to add a compile time check to check whether the Security framework has been added to the project or not. What I mean by added to the project is whether it has been added in the Link Binary With Libraries build phases for the current target.
Now, I know that questions with similar titles have been asked multiple times, and this particular question seemed to be super close to what I'm looking for, but I did not find an answer there either.
I've been using:
#ifdef __SENTINEL_VALUE_
..conditional code here..
#endif
code, but this only works if the framework header declares the sentinel value in the main header. Let me provide two examples to compare and contrast:
SystemConfiguration.framework has a framework header SystemConfiguration.h which includes all the sub headers, but also declares its own sentinel value, namely _SYSTEMCONFIGURATION_H
Thus, checking it using #ifdef _SYSTEMCONFIGURATION_H works perfectly. However, for Security.framework, the framework header, Security.h does not declare its own sentinel value. Each of its sub headers declare their own sentinel value, but since they are being imported in Security.h, the sentinel value gets defined. Therefore, even if Security.framework is not included in the project (not linked in the build phases), an #ifndef for one of its sub headers returns a false value, since the sentinel value is defined owing to its import in the Security.h file (not to mention that this approach of checking for a sub header of a framework header makes me feel a little sad).
So, my question is: For a unique case like Security.framework, what would be the appropriate compile time check to check whether the framework has been added to the Link Binary With Libraries phase (if such a check exists).
Additionally, I know of the NSClassFromString() method and the NS_CLASS_AVAILABLE macros, but I'm not looking for a run-time solution.
Thanks in advance all!
Cheers!