Mac SDK: using latest SDK but ensuring backwards compatibility with earlier deployment target

后端 未结 6 913
死守一世寂寞
死守一世寂寞 2020-12-31 06:39

As always when Apple updates OS X, the latest XCode 4.4 dumps the older (10.6) SDK and I find myself needing to use the 10.7 SDK (or 10.8 I suppose) and setting my deploymen

6条回答
  •  没有蜡笔的小新
    2020-12-31 07:09

    I check my code by hacking around Availability.h to get the compiler to flag weak-linked symbols as warnings/errors. In my current (Xcode 5/llvm) incarnation, I'm using the code below. It warns whenever I use a symbol introduced in iOS 6.0 or later. I think it's fairly self-explanatory. The macros seem to need updating at each and every SDK update, so tread carefully. Oh, and you loose deprecation warnings too, so I only use this once in a while to double-check my conditional code.

    #undef __NSi_6_0
    #define __NSi_6_0 deprecated=1.0
    #undef __NSi_6_1
    #define __NSi_6_1 deprecated=1.0
    #undef __NSi_7_0
    #define __NSi_7_0 deprecated=1.0
    
    #undef __NSd_6_0
    #define __NSd_6_0
    #undef __NSd_6_1
    #define __NSd_6_1
    #undef __NSd_7_0
    #define  __NSd_7_0
    

    See also http://iphone.m20.nl/wp/2013/10/xcode-5-and-flagging-weak-linked-unavailable-symbols-from-a-newer-sdk/

提交回复
热议问题