Skip to content

Unify all platform conditional macros. #730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Parse/Internal/Object/PFObjectPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

- (PFObjectEstimatedData *)_estimatedData;

#if PARSE_OSX_ONLY
#if PF_TARGET_OS_OSX
// Not available publicly, but available for testing

- (instancetype)refresh;
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/PFApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ + (instancetype)currentApplication {
///--------------------------------------

- (BOOL)isAppStoreEnvironment {
#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
#if TARGET_OS_IOS && !TARGET_IPHONE_SIMULATOR
return ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"] == nil);
#endif

Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/PFDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ - (NSString *)operatingSystemBuild {

- (BOOL)isJailbroken {
BOOL jailbroken = NO;
#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
#if TARGET_OS_IOS && !TARGET_IPHONE_SIMULATOR
DIR *dir = opendir("/");
if (dir != NULL) {
jailbroken = YES;
Expand Down
26 changes: 13 additions & 13 deletions Parse/Internal/PFFileManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
static NSString *const _PFFileManagerParseDirectoryName = @"Parse";

static NSDictionary *_PFFileManagerDefaultDirectoryFileAttributes() {
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#if !PF_TARGET_OS_OSX
return @{ NSFileProtectionKey : NSFileProtectionCompleteUntilFirstUserAuthentication };
#else
return nil;
Expand All @@ -28,7 +28,7 @@

static NSDataWritingOptions _PFFileManagerDefaultDataWritingOptions() {
NSDataWritingOptions options = NSDataWritingAtomic;
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#if !PF_TARGET_OS_OSX
options |= NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication;
#endif
return options;
Expand Down Expand Up @@ -92,7 +92,7 @@ + (BFTask *)createDirectoryIfNeededAsyncAtPath:(NSString *)path
}
}

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#if TARGET_OS_IOS || TARGET_OS_WATCH // No backups for Apple TV, since everything is cache.
if (options & PFFileManagerOptionSkipBackup) {
[self _skipBackupOnPath:path];
}
Expand Down Expand Up @@ -246,7 +246,12 @@ - (instancetype)initWithApplicationIdentifier:(NSString *)applicationIdentifier
- (NSString *)parseDefaultDataDirectoryPath {
// NSHomeDirectory: Returns the path to either the user's or application's
// home directory, depending on the platform. Sandboxed by default on iOS.
#if PARSE_IOS_ONLY
#if PF_TARGET_OS_OSX
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *directoryPath = [paths firstObject];
directoryPath = [directoryPath stringByAppendingPathComponent:_PFFileManagerParseDirectoryName];
directoryPath = [directoryPath stringByAppendingPathComponent:self.applicationIdentifier];
#else
NSString *directoryPath = nil;
if (self.applicationGroupIdentifier) {
NSURL *containerPath = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:self.applicationGroupIdentifier];
Expand All @@ -255,11 +260,6 @@ - (NSString *)parseDefaultDataDirectoryPath {
} else {
return [self parseLocalSandboxDataDirectoryPath];
}
#else
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *directoryPath = [paths firstObject];
directoryPath = [directoryPath stringByAppendingPathComponent:_PFFileManagerParseDirectoryName];
directoryPath = [directoryPath stringByAppendingPathComponent:self.applicationIdentifier];
#endif

BFTask *createDirectoryTask = [[self class] createDirectoryIfNeededAsyncAtPath:directoryPath
Expand All @@ -271,7 +271,9 @@ - (NSString *)parseDefaultDataDirectoryPath {
}

- (NSString *)parseLocalSandboxDataDirectoryPath {
#if TARGET_OS_IPHONE
#if PF_TARGET_OS_OSX
return [self parseDefaultDataDirectoryPath];
#else
NSString *library = [NSHomeDirectory() stringByAppendingPathComponent:@"Library"];
NSString *privateDocuments = [library stringByAppendingPathComponent:@"Private Documents"];
NSString *directoryPath = [privateDocuments stringByAppendingPathComponent:_PFFileManagerParseDirectoryName];
Expand All @@ -281,8 +283,6 @@ - (NSString *)parseLocalSandboxDataDirectoryPath {
[createDirectoryTask waitForResult:nil withMainThreadWarning:NO];

return directoryPath;
#else
return [self parseDefaultDataDirectoryPath];
#endif
}

Expand All @@ -294,7 +294,7 @@ - (NSString *)parseCacheItemPathForPathComponent:(NSString *)component {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *folderPath = paths.firstObject;
folderPath = [folderPath stringByAppendingPathComponent:_PFFileManagerParseDirectoryName];
#if !TARGET_OS_IPHONE
#if PF_TARGET_OS_OSX
// We append the applicationId in case the OS X application isn't sandboxed,
// to avoid collisions in the generic ~/Library/Caches/Parse/------ dir.
folderPath = [folderPath stringByAppendingPathComponent:self.applicationIdentifier];
Expand Down
6 changes: 4 additions & 2 deletions Parse/Internal/PFLocationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

#import <Foundation/Foundation.h>

#import <Parse/PFConstants.h>

@class CLLocation;
@class CLLocationManager;

#if TARGET_OS_IPHONE
#if !PF_TARGET_OS_OSX

@class UIApplication;

Expand All @@ -39,7 +41,7 @@ typedef void(^PFLocationManagerLocationUpdateBlock)(CLLocation *location, NSErro

- (instancetype)initWithSystemLocationManager:(CLLocationManager *)manager;

#if TARGET_OS_IPHONE
#if !PF_TARGET_OS_OSX

- (instancetype)initWithSystemLocationManager:(CLLocationManager *)manager
application:(UIApplication *)application
Expand Down
2 changes: 1 addition & 1 deletion Parse/Internal/PFReachability.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ + (BOOL)_reachabilityStateForFlags:(SCNetworkConnectionFlags)flags {
}
}

#if TARGET_OS_IPHONE
#if !PF_TARGET_OS_OSX
if (((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) &&
((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)) {
// ... but WWAN connections are OK if the calling application
Expand Down
5 changes: 1 addition & 4 deletions Parse/PFConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ extern NSInteger const PARSE_API_VERSION;
#pragma mark - Platform
///--------------------------------------

#define PARSE_IOS_ONLY (TARGET_OS_IPHONE)
#define PARSE_OSX_ONLY (TARGET_OS_MAC && !(TARGET_OS_IPHONE))

extern NSString *const _Nonnull kPFDeviceType;

///--------------------------------------
Expand Down Expand Up @@ -468,7 +465,7 @@ extern NSString *const _Nonnull PFNetworkNotificationURLResponseBodyUserInfoKey;
#endif

#ifndef PF_TARGET_OS_OSX
# define PF_TARGET_OS_OSX TARGET_OS_MAC && !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV
# define PF_TARGET_OS_OSX (TARGET_OS_MAC && !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV)
#endif

///--------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Parse/PFObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ NS_REQUIRES_PROPERTY_DEFINITIONS
*/
@property (nonatomic, assign, readonly, getter=isDataAvailable) BOOL dataAvailable;

#if PARSE_IOS_ONLY
#if TARGET_OS_IOS

/**
Refreshes the PFObject with the current data from the server.
Expand Down
5 changes: 3 additions & 2 deletions Parse/PFPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "PFQueryPrivate.h"
#import "PFUserPrivate.h"
#import "Parse_Private.h"
#import "PFApplication.h"

static Class _pushInternalUtilClass = nil;

Expand Down Expand Up @@ -286,9 +287,9 @@ + (void)unsubscribeFromChannelInBackground:(NSString *)channel block:(PFBooleanR
#pragma mark - Handling Notifications
///--------------------------------------

#if PARSE_IOS_ONLY
#if TARGET_OS_IOS
+ (void)handlePush:(NSDictionary *)userInfo {
UIApplication *application = [UIApplication sharedApplication];
UIApplication *application = [PFApplication currentApplication].systemApplication;
if (application.applicationState != UIApplicationStateActive) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Parse/Parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (NSString *)containingApplicationBundleIdentifierForDataSharing PF_WATCH_UNAVAILABLE PF_TV_UNAVAILABLE;

#if PARSE_IOS_ONLY
#if TARGET_OS_IOS

///--------------------------------------
#pragma mark - Configuring UI Settings
Expand Down
2 changes: 1 addition & 1 deletion Parse/Parse.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ + (BOOL)isLocalDatastoreEnabled {
#pragma mark - User Interface
///--------------------------------------

#if PARSE_IOS_ONLY
#if TARGET_OS_IOS

+ (void)offlineMessagesEnabled:(BOOL)enabled {
// Deprecated method - shouldn't do anything.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ + (NSString *)sharedTestDirectoryPath {
}

+ (NSString *)sharedTestDirectoryPathForGroupIdentifier:(NSString *)groupIdentifier {
#if TARGET_OS_IPHONE
return [[PFExtensionDataSharingTestHelper sharedTestDirectoryPath] stringByAppendingPathComponent:groupIdentifier];
#else
#if PF_TARGET_OS_OSX
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
return [paths firstObject];
#else
return [[PFExtensionDataSharingTestHelper sharedTestDirectoryPath] stringByAppendingPathComponent:groupIdentifier];
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import "CLLocationManager+TestAdditions.h"

#import <Parse/PFConstants.h>

#import "PFTestSwizzlingUtilities.h"

@interface CLLocationManager ()
Expand All @@ -31,7 +33,7 @@ @implementation CLLocationManager (TestAdditions)

+ (void)setMockingEnabled:(BOOL)enabled {
// There is no ability to use real CLLocationManager on Mac, due to permission requests
#if PARSE_OSX_ONLY
#if PF_TARGET_OS_OSX
if (!enabled) {
return;
}
Expand Down