Skip to content

Commit aa0ab1c

Browse files
committed
Fix availability preprocessor macros
- Add parentheses around each macro's definition to ensure that the boolean statements are evaluated correctly - Add some documentation to these preprocessor defines This should fix PureLayout#58
1 parent b4d3210 commit aa0ab1c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

PureLayout/PureLayout/PureLayoutDefines.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@
3131

3232
#import <Foundation/Foundation.h>
3333

34-
#define __PureLayout_MinBaseSDK_iOS_8_0 TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1
35-
#define __PureLayout_MinSysVer_iOS_7_0 TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1
36-
#define __PureLayout_MinSysVer_iOS_8_0 TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1
34+
// Define some preprocessor macros to check for a minimum Base SDK. These are used to prevent compile-time errors in older versions of Xcode.
35+
#define __PureLayout_MinBaseSDK_iOS_8_0 (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1)
36+
#define __PureLayout_MinBaseSDK_OSX_10_10 (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9)
3737

38-
#define __PureLayout_MinBaseSDK_OSX_10_10 !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9
39-
#define __PureLayout_MinSysVer_OSX_10_9 !TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4
38+
// Define some preprocessor macros to check for a minimum System Version. These are used to prevent runtime crashes on older versions of iOS/OS X.
39+
#define __PureLayout_MinSysVer_iOS_7_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
40+
#define __PureLayout_MinSysVer_iOS_8_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1)
41+
#define __PureLayout_MinSysVer_OSX_10_9 (!TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4)
4042

43+
// Define generic AL-prefixed macros for the types/constants/etc that have slight naming variations across iOS and OS X, which allows the same code to be platform-independent
4144
#if TARGET_OS_IPHONE
4245
# import <UIKit/UIKit.h>
43-
4446
# define ALView UIView
4547
# define ALEdgeInsets UIEdgeInsets
4648
# define ALEdgeInsetsZero UIEdgeInsetsZero
@@ -59,7 +61,6 @@
5961
# define ALLayoutPriorityFittingSizeCompression ALLayoutPriorityFittingSizeLevel
6062
#else
6163
# import <Cocoa/Cocoa.h>
62-
6364
# define ALView NSView
6465
# define ALEdgeInsets NSEdgeInsets
6566
# define ALEdgeInsetsZero NSEdgeInsetsMake(0, 0, 0, 0)

0 commit comments

Comments
 (0)