i'm working on project has class referencing security.h framework. since reusable class, , might used in multiple projects, wish add compile time check check whether security framework has been added project or not. mean added project whether has been added in link binary libraries build phases current target.
now, know questions similar titles have been asked multiple times, , this particular question seemed super close i'm looking for, did not find answer there either.
i've been using:
#ifdef __sentinel_value_ ..conditional code here.. #endif code, only works if framework header declares sentinel value in main header. let me provide 2 examples compare , contrast:
systemconfiguration.framework has framework header systemconfiguration.h includes sub headers, declares own sentinel value, namely _systemconfiguration_h
thus, checking using #ifdef _systemconfiguration_h works perfectly. however, security.framework, framework header, security.h not declare own sentinel value. each of sub headers declare own sentinel value, since being imported in security.h, sentinel value gets defined. therefore, if security.framework not included in project (not linked in build phases), #ifndef 1 of sub headers returns false value, since sentinel value defined owing import in security.h file (not mention approach of checking sub header of framework header makes me feel little sad).
so, question is: unique case security.framework, appropriate compile time check check whether framework has been added link binary libraries phase (if such check exists).
additionally, know of nsclassfromstring() method , ns_class_available macros, i'm not looking run-time solution.
thanks in advance all!
cheers!
the link phase follows compile phase, there no way compiler can tell whether framework linked project.
if project's product framework, dynamic library or executable, link binary against security framework, , fine.
if project's product static library, need confirm project produces final executable binary link against security framework. recommended way provide install , usage documentation, , possibly sample.
Comments
Post a Comment