Check for framework's existence at compile time?

前端 未结 2 938
情深已故
情深已故 2020-12-30 01:28

I\'m working on an open-source project that can optionally use a closed-source framework. If the closed-source framework is included in the project, there will be additional

2条回答
  •  天命终不由人
    2020-12-30 01:52

    I recommend reading the Mac Developer Library : Framework Programming Guide (which includes a section on Weak Linking).

    1. What do you mean by "exists" or "included in the project"? Do you mean added to the "Link Binary With Libraries" build phase (as described by Including Frameworks)? All that does is affect the linking, not the compilation, build phase. To see this, build. Then, search for -framework in the build log of Xcode's Log Navigator.

      So, yes, if you want to affect the compilation of the code you provided, you could manually define the macro _MY_FRAMEWORK_EXISTS.

    2. I don't really understand what you are trying to do. Can you explain what you want at a higher level? Perhaps, there's a better way to go about it.

      "Minimal overhead" is nice, but too much magic might be confusing. For example, Xcode's magic hides what really happens when including a framework.

      I also recommend checking out how the Facebook SDK for iOS works for high & low-level ideas. It might do the kinds of things you want to do.

提交回复
热议问题