aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase
diff options
context:
space:
mode:
authorGravatar Mathew Huusko V <mhuusko5@gmail.com>2017-06-02 18:42:17 +0100
committerGravatar Paul Beusterien <paulbeusterien@google.com>2017-06-02 10:42:17 -0700
commit5c59342e6e19989c012877362af529b3d5d0abeb (patch)
tree457f5da7c41ee45b8d3f55f83017fff2ab718781 /Firebase
parent6f700dd6c81711a8605c2587b4f2acfd4e07466b (diff)
macOS (#38)
* Example/Core: create macOS app/tests target * Example/Core: Core_Example/Tests -> Core_Example/Tests_iOS * Example/Core: macOS building/tests passing * Example/Database: separate iOS/macOS targets * BuildFrameworks: macOS * .travis.yml, test.sh: AllUnitTests -> AllUnitTests_iOS * test.sh: add AllUnitTests_macOS * Example/Storage: Example/Tests->_iOS * Example/Storage: macOS * test.sh: try to prevent double error 65 * test.sh: build before test * Example/Auth|Messaging: -> _iOS * Example/Auth: macOS build * Example/Auth: macOS passing * Example/Firebase: pod de/re-integrate; fix static DerivedData references; copy phase for OCMock * Example/Firebase: manually copied OCMock, Products Dir vs. Frameworks * Example/Firebase: copied OCMock, prevent header removal * Example/Storage: integration tests sdk fix * Example/Auth: macOS exclude FIRAuthAppCredentialManager; cleanup * Firebase/Core: remove nullability annotation * Firebase/Core|Database: correct TARGET_X usage for correctness and anticipation of OS_WATCH|TV branches * build.swift: style fix * Firebase/Core: FIRLogger: fix macOS intermittent va_list error
Diffstat (limited to 'Firebase')
-rw-r--r--Firebase/Auth/FirebaseAuth.podspec9
-rw-r--r--Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m1
-rw-r--r--Firebase/Auth/Source/FIRAuth.h9
-rw-r--r--Firebase/Auth/Source/FIRAuth.m37
-rw-r--r--Firebase/Auth/Source/FIRUser.h2
-rw-r--r--Firebase/Auth/Source/FIRUser.m11
-rw-r--r--Firebase/Auth/Source/Private/FIRAuth_Internal.h4
-rw-r--r--Firebase/Auth/Source/RPCs/FIRAuthBackend.h4
-rw-r--r--Firebase/Auth/Source/RPCs/FIRAuthBackend.m9
-rw-r--r--Firebase/Core/FIRApp.h1
-rw-r--r--Firebase/Core/FIRAppEnvironmentUtil.m28
-rw-r--r--Firebase/Core/FIRNetworkURLSession.m23
-rw-r--r--Firebase/Core/FIRReachabilityChecker.m8
-rw-r--r--Firebase/Core/FirebaseCore.podspec1
-rw-r--r--Firebase/Core/Private/FIRAppEnvironmentUtil.h9
-rw-r--r--Firebase/Core/Private/FIRLogger.h2
-rw-r--r--Firebase/Database/Core/FPersistentConnection.m6
-rw-r--r--Firebase/Database/Core/FRepo.m6
-rw-r--r--Firebase/Database/FirebaseDatabase.podspec1
-rw-r--r--Firebase/Database/Persistence/FLevelDBStorageEngine.m6
-rw-r--r--Firebase/Database/Realtime/FWebSocketConnection.m4
-rw-r--r--Firebase/Database/third_party/SocketRocket/FSRWebSocket.m6
-rw-r--r--Firebase/Storage/FIRStorageUtils.m6
-rw-r--r--Firebase/Storage/FirebaseStorage.podspec4
24 files changed, 159 insertions, 38 deletions
diff --git a/Firebase/Auth/FirebaseAuth.podspec b/Firebase/Auth/FirebaseAuth.podspec
index 74aa07c..980fedb 100644
--- a/Firebase/Auth/FirebaseAuth.podspec
+++ b/Firebase/Auth/FirebaseAuth.podspec
@@ -20,8 +20,17 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
s.source = { :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/Firebase'
s.ios.deployment_target = '7.0'
+ s.osx.deployment_target = '10.10'
s.source_files = '**/*.[mh]'
+ s.osx.exclude_files =
+ 'Source/**/FIRAuthAppDelegateProxy.[mh]',
+ 'Source/**/FIRAuthNotificationManager.[mh]',
+ 'Source/**/FIRAuthAppCredentialManager.[mh]',
+ 'Source/**/FIRAuthAPNSTokenManager.[mh]',
+ 'Source/**/FIRAuthAPNSTokenType.[mh]',
+ 'Source/**/FIRAuthAPNSToken.[mh]',
+ 'Source/**/FIRPhoneAuthProvider.[mh]'
s.public_header_files =
'Source/FirebaseAuth.h',
'Source/FirebaseAuthVersion.h',
diff --git a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m
index b9bf577..c7e8bb1 100644
--- a/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m
+++ b/Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthCredential.m
@@ -16,7 +16,6 @@
#import "FIRPhoneAuthCredential.h"
-#import "FIRPhoneAuthProvider.h"
#import "FIRPhoneAuthCredential_Internal.h"
#import "FIRAuthCredential_Internal.h"
#import "FIRAuthExceptionUtils.h"
diff --git a/Firebase/Auth/Source/FIRAuth.h b/Firebase/Auth/Source/FIRAuth.h
index 6e59e86..65b55d6 100644
--- a/Firebase/Auth/Source/FIRAuth.h
+++ b/Firebase/Auth/Source/FIRAuth.h
@@ -16,10 +16,13 @@
#import <Foundation/Foundation.h>
-#import "FIRAuthAPNSTokenType.h"
#import "FIRAuthErrors.h"
#import "FIRAuthSwiftNameSupport.h"
+#if TARGET_OS_IOS
+#import "FIRAuthAPNSTokenType.h"
+#endif
+
@class FIRApp;
@class FIRAuth;
@class FIRAuthCredential;
@@ -249,6 +252,7 @@ FIR_SWIFT_NAME(Auth)
*/
@property(nonatomic, strong, readonly, nullable) FIRUser *currentUser;
+#if TARGET_OS_IOS
/** @property APNSToken
@brief The APNs token used for phone number authentication. The type of the token (production
or sandbox) will be attempted to be automatcially detected.
@@ -256,6 +260,7 @@ FIR_SWIFT_NAME(Auth)
by either setting this property or by calling @c setAPNSToken:type:
*/
@property(nonatomic, strong, nullable) NSData *APNSToken;
+#endif
/** @fn init
@brief Please access auth instances using @c FIRAuth.auth and @c FIRAuth.authForApp:.
@@ -587,6 +592,7 @@ FIR_SWIFT_NAME(Auth)
*/
- (void)removeIDTokenDidChangeListener:(FIRIDTokenDidChangeListenerHandle)listenerHandle;
+#if TARGET_OS_IOS
/** @fn setAPNSToken:type:
@brief Sets the APNs token along with its type.
@remarks If swizzling is disabled, the APNs Token must be set for phone number auth to work,
@@ -606,6 +612,7 @@ FIR_SWIFT_NAME(Auth)
for phone number auth to work.
*/
- (BOOL)canHandleNotification:(NSDictionary *)userInfo;
+#endif
@end
diff --git a/Firebase/Auth/Source/FIRAuth.m b/Firebase/Auth/Source/FIRAuth.m
index 5b1da8c..dca0c1d 100644
--- a/Firebase/Auth/Source/FIRAuth.m
+++ b/Firebase/Auth/Source/FIRAuth.m
@@ -23,10 +23,6 @@
#import "AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.h"
#import "AuthProviders/Phone/FIRPhoneAuthCredential_Internal.h"
#import "Private/FIRAdditionalUserInfo_Internal.h"
-#import "Private/FIRAuthAPNSToken.h"
-#import "Private/FIRAuthAPNSTokenManager.h"
-#import "Private/FIRAuthAppCredentialManager.h"
-#import "Private/FIRAuthAppDelegateProxy.h"
#import "Private/FIRAuthCredential_Internal.h"
#import "Private/FIRAuthDataResult_Internal.h"
#import "Private/FIRAuthDispatcher.h"
@@ -34,7 +30,6 @@
#import "FIRAuthExceptionUtils.h"
#import "Private/FIRAuthGlobalWorkQueue.h"
#import "Private/FIRAuthKeychain.h"
-#import "Private/FIRAuthNotificationManager.h"
#import "Private/FIRUser_Internal.h"
#import "FirebaseAuth.h"
#import "FIRAuthBackend.h"
@@ -59,6 +54,14 @@
#import "FIRVerifyPhoneNumberRequest.h"
#import "FIRVerifyPhoneNumberResponse.h"
+#if TARGET_OS_IOS
+#import "Private/FIRAuthAPNSToken.h"
+#import "Private/FIRAuthAPNSTokenManager.h"
+#import "Private/FIRAuthAppCredentialManager.h"
+#import "Private/FIRAuthAppDelegateProxy.h"
+#import "Private/FIRAuthNotificationManager.h"
+#endif
+
#pragma mark - Constants
NSString *const FIRAuthStateDidChangeInternalNotification =
@@ -173,7 +176,11 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
#pragma mark - FIRAuth
+#if TARGET_OS_IOS
@interface FIRAuth () <FIRAuthAppDelegateHandler>
+#else
+@interface FIRAuth ()
+#endif
/** @property firebaseAppId
@brief The Firebase app ID.
@@ -309,6 +316,8 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
FIRLogInfo(kFIRLoggerAuth, @"I-AUT000002", @"Token auto-refresh enabled.");
strongSelf->_autoRefreshTokens = YES;
[strongSelf scheduleAutoTokenRefresh];
+
+ #if TARGET_OS_IOS // TODO: Is a similar mechanism needed on macOS?
strongSelf->_applicationDidBecomeActiveObserver = [[NSNotificationCenter defaultCenter]
addObserverForName:UIApplicationDidBecomeActiveNotification
object:nil
@@ -332,6 +341,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
strongSelf->_isAppInBackground = YES;
}
}];
+ #endif
}
if (!strongSelf.currentUser) {
dispatch_async(dispatch_get_main_queue(), ^{
@@ -378,14 +388,20 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
FIRLogError(kFIRLoggerAuth, @"I-AUT000001",
@"Error loading saved user when starting up: %@", error);
}
+
+ #if TARGET_OS_IOS
// Initialize for phone number auth.
_tokenManager =
[[FIRAuthAPNSTokenManager alloc] initWithApplication:[UIApplication sharedApplication]];
+
_appCredentialManager = [[FIRAuthAppCredentialManager alloc] initWithKeychain:_keychain];
+
_notificationManager =
[[FIRAuthNotificationManager alloc] initWithApplication:[UIApplication sharedApplication]
appCredentialManager:_appCredentialManager];
+
[[FIRAuthAppDelegateProxy sharedInstance] addHandler:self];
+ #endif
}
return self;
}
@@ -398,12 +414,15 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
[defaultCenter removeObserver:handleToRemove];
[_listenerHandles removeLastObject];
}
+
+ #if TARGET_OS_IOS
[defaultCenter removeObserver:_applicationDidBecomeActiveObserver
name:UIApplicationDidBecomeActiveNotification
object:nil];
[defaultCenter removeObserver:_applicationDidEnterBackgroundObserver
name:UIApplicationDidEnterBackgroundNotification
object:nil];
+ #endif
}
}
@@ -520,6 +539,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
return;
}
+ #if TARGET_OS_IOS
if ([credential isKindOfClass:[FIRPhoneAuthCredential class]]) {
// Special case for phone auth credential
FIRPhoneAuthCredential *phoneCredential = (FIRPhoneAuthCredential *)credential;
@@ -533,6 +553,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
}];
return;
}
+ #endif
FIRVerifyAssertionRequest *request =
[[FIRVerifyAssertionRequest alloc] initWithAPIKey:_APIKey providerID:credential.provider];
@@ -839,7 +860,8 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
}
}
-- (NSData *)APNStoken {
+#if TARGET_OS_IOS
+- (NSData *)APNSToken {
__block NSData *result = nil;
dispatch_sync(FIRAuthGlobalWorkQueue(), ^{
result = _tokenManager.token.data;
@@ -864,9 +886,11 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
});
return result;
}
+#endif
#pragma mark - Internal Methods
+#if TARGET_OS_IOS
/** @fn signInWithPhoneCredential:callback:
@brief Signs in using a phone credential.
@param credential The Phone Auth credential used to sign in.
@@ -922,6 +946,7 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
callback:callback];
}];
}
+#endif
- (void)notifyListenersOfAuthStateChangeWithUser:(FIRUser *)user token:(NSString *)token {
if (user && _autoRefreshTokens) {
diff --git a/Firebase/Auth/Source/FIRUser.h b/Firebase/Auth/Source/FIRUser.h
index ebe8b81..9e3ac77 100644
--- a/Firebase/Auth/Source/FIRUser.h
+++ b/Firebase/Auth/Source/FIRUser.h
@@ -158,6 +158,7 @@ FIR_SWIFT_NAME(User)
completion:(nullable FIRUserProfileChangeCallback)completion
FIR_SWIFT_NAME(updatePassword(to:completion:));
+#if TARGET_OS_IOS
/** @fn updatePhoneNumberCredential:completion:
@brief Updates the phone number for the user. On success, the cached user profile data is
updated.
@@ -181,6 +182,7 @@ FIR_SWIFT_NAME(User)
*/
- (void)updatePhoneNumberCredential:(FIRPhoneAuthCredential *)phoneNumberCredential
completion:(nullable FIRUserProfileChangeCallback)completion;
+#endif
/** @fn profileChangeRequest
@brief Creates an object which may be used to change the user's profile data.
diff --git a/Firebase/Auth/Source/FIRUser.m b/Firebase/Auth/Source/FIRUser.m
index f0c3226..c45539c 100644
--- a/Firebase/Auth/Source/FIRUser.m
+++ b/Firebase/Auth/Source/FIRUser.m
@@ -19,7 +19,6 @@
#import "AuthProviders/EmailPassword/FIREmailPasswordAuthCredential.h"
#import "AuthProviders/EmailPassword/FIREmailAuthProvider.h"
#import "AuthProviders/Phone/FIRPhoneAuthCredential_Internal.h"
-#import "AuthProviders/Phone/FIRPhoneAuthProvider.h"
#import "Private/FIRAdditionalUserInfo_Internal.h"
#import "FIRAuth.h"
#import "Private/FIRAuthCredential_Internal.h"
@@ -48,6 +47,10 @@
#import "FIRVerifyPhoneNumberRequest.h"
#import "FIRVerifyPhoneNumberResponse.h"
+#if TARGET_OS_IOS
+#import "AuthProviders/Phone/FIRPhoneAuthProvider.h"
+#endif
+
NS_ASSUME_NONNULL_BEGIN
/** @var kUserIDCodingKey
@@ -602,6 +605,7 @@ static void callInMainThreadWithAuthDataResultAndError(
});
}
+#if TARGET_OS_IOS
/** @fn internalUpdatePhoneNumberCredential:completion:
@brief Updates the phone number for the user. On success, the cached user profile data is
updated.
@@ -654,6 +658,7 @@ static void callInMainThreadWithAuthDataResultAndError(
}];
});
}
+#endif
- (FIRUserProfileChangeRequest *)profileChangeRequest {
__block FIRUserProfileChangeRequest *result;
@@ -839,6 +844,7 @@ static void callInMainThreadWithAuthDataResultAndError(
return;
}
+ #if TARGET_OS_IOS
if ([credential isKindOfClass:[FIRPhoneAuthCredential class]]) {
FIRPhoneAuthCredential *phoneAuthCredential = (FIRPhoneAuthCredential *)credential;
[self internalUpdatePhoneNumberCredential:phoneAuthCredential
@@ -851,6 +857,7 @@ static void callInMainThreadWithAuthDataResultAndError(
}];
return;
}
+ #endif
[_taskQueue enqueueTask:^(FIRAuthSerialTaskCompletionBlock _Nonnull complete) {
CallbackWithAuthDataResultAndError completeWithError =
@@ -960,11 +967,13 @@ static void callInMainThreadWithAuthDataResultAndError(
[mutableProviderData removeObjectForKey:provider];
_providerData = [mutableProviderData copy];
+ #if TARGET_OS_IOS
// After successfully unlinking a phone auth provider, remove the phone number from the
// cached user info.
if ([provider isEqualToString:FIRPhoneAuthProviderID]) {
_phoneNumber = nil;
}
+ #endif
}
if (response.IDToken && response.refreshToken) {
FIRSecureTokenService *tokenService =
diff --git a/Firebase/Auth/Source/Private/FIRAuth_Internal.h b/Firebase/Auth/Source/Private/FIRAuth_Internal.h
index bdbefce..afcd899 100644
--- a/Firebase/Auth/Source/Private/FIRAuth_Internal.h
+++ b/Firebase/Auth/Source/Private/FIRAuth_Internal.h
@@ -16,9 +16,11 @@
#import "FIRAuth.h"
+#if TARGET_OS_IOS
@class FIRAuthAPNSTokenManager;
@class FIRAuthAppCredentialManager;
@class FIRAuthNotificationManager;
+#endif
NS_ASSUME_NONNULL_BEGIN
@@ -46,6 +48,7 @@ extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey;
*/
@property(nonatomic, copy, readonly) NSString *APIKey;
+#if TARGET_OS_IOS
/** @property tokenManager
@brief The manager for APNs tokens used by phone number auth.
*/
@@ -60,6 +63,7 @@ extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey;
@brief The manager for remote notifications used by phone number auth.
*/
@property(nonatomic, strong, readonly) FIRAuthNotificationManager *notificationManager;
+#endif
/** @fn initWithAPIKey:appName:
@brief Designated initializer.
diff --git a/Firebase/Auth/Source/RPCs/FIRAuthBackend.h b/Firebase/Auth/Source/RPCs/FIRAuthBackend.h
index 519a6e7..521cf16 100644
--- a/Firebase/Auth/Source/RPCs/FIRAuthBackend.h
+++ b/Firebase/Auth/Source/RPCs/FIRAuthBackend.h
@@ -312,6 +312,7 @@ typedef void (^FIRVerifyClientResponseCallback)
+ (void)deleteAccount:(FIRDeleteAccountRequest *)request
callback:(FIRDeleteCallBack)callback;
+#if TARGET_OS_IOS
/** @fn sendVerificationCode:callback:
@brief Calls the sendVerificationCode endpoint, which is responsible for sending the
verification code to a phone number specified in the request parameters.
@@ -338,6 +339,7 @@ typedef void (^FIRVerifyClientResponseCallback)
*/
+ (void)verifyClient:(FIRVerifyClientRequest *)request
callback:(FIRVerifyClientResponseCallback)callback;
+#endif
@end
@@ -455,6 +457,7 @@ typedef void (^FIRVerifyClientResponseCallback)
- (void)deleteAccount:(FIRDeleteAccountRequest *)request
callback:(FIRDeleteCallBack)callback;
+#if TARGET_OS_IOS
/** @fn sendVerificationCode:callback:
@brief Calls the sendVerificationCode endpoint, which is responsible for sending the
verification code to a phone number specified in the request parameters.
@@ -481,6 +484,7 @@ typedef void (^FIRVerifyClientResponseCallback)
*/
- (void)verifyClient:(FIRVerifyClientRequest *)request
callback:(FIRVerifyClientResponseCallback)callback;
+#endif
/** @fn resetPassword:callback
@brief Calls the resetPassword endpoint, which is responsible for resetting a user's password
diff --git a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
index 3efc602..3b899f0 100644
--- a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
+++ b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
@@ -17,7 +17,6 @@
#import "FIRAuthBackend.h"
#import "../AuthProviders/Phone/FIRPhoneAuthCredential_Internal.h"
-#import "../AuthProviders/Phone/FIRPhoneAuthProvider.h"
#import "../Private/FIRAuthErrorUtils.h"
#import "../Private/FIRAuthGlobalWorkQueue.h"
#import "FirebaseAuth.h"
@@ -54,6 +53,10 @@
#import <GTMSessionFetcher/GTMSessionFetcher.h>
#import <GTMSessionFetcher/GTMSessionFetcherService.h>
+#if TARGET_OS_IOS
+#import "../AuthProviders/Phone/FIRPhoneAuthProvider.h"
+#endif
+
/** @var kIosBundleIdentifierHeader
@brief HTTP header name for iOS bundle ID.
*/
@@ -374,6 +377,7 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
[[self implementation] deleteAccount:request callback:callback];
}
+#if TARGET_OS_IOS
+ (void)sendVerificationCode:(FIRSendVerificationCodeRequest *)request
callback:(FIRSendVerificationCodeResponseCallback)callback {
[[self implementation] sendVerificationCode:request callback:callback];
@@ -387,6 +391,7 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
+ (void)verifyClient:(id)request callback:(FIRVerifyClientResponseCallback)callback {
[[self implementation] verifyClient:request callback:callback];
}
+#endif
+ (void)resetPassword:(FIRResetPasswordRequest *)request
callback:(FIRResetPasswordCallback)callback {
@@ -560,6 +565,7 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
[self postWithRequest:request response:response callback:callback];
}
+#if TARGET_OS_IOS
- (void)sendVerificationCode:(FIRSendVerificationCodeRequest *)request
callback:(FIRSendVerificationCodeResponseCallback)callback {
FIRSendVerificationCodeResponse *response = [[FIRSendVerificationCodeResponse alloc] init];
@@ -606,6 +612,7 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
callback(response, nil);
}];
}
+#endif
- (void)resetPassword:(FIRResetPasswordRequest *)request
callback:(FIRResetPasswordCallback)callback {
diff --git a/Firebase/Core/FIRApp.h b/Firebase/Core/FIRApp.h
index 7f1d0c7..00781ad 100644
--- a/Firebase/Core/FIRApp.h
+++ b/Firebase/Core/FIRApp.h
@@ -15,7 +15,6 @@
*/
#import <Foundation/Foundation.h>
-#import <UIKit/UIKit.h>
#import "FIRCoreSwiftNameSupport.h"
diff --git a/Firebase/Core/FIRAppEnvironmentUtil.m b/Firebase/Core/FIRAppEnvironmentUtil.m
index b88b432..b3c6913 100644
--- a/Firebase/Core/FIRAppEnvironmentUtil.m
+++ b/Firebase/Core/FIRAppEnvironmentUtil.m
@@ -23,7 +23,7 @@
/// The encryption info struct and constants are missing from the iPhoneSimulator SDK, but not from
/// the iPhoneOS or Mac OS X SDKs. Since one doesn't ever ship a Simulator binary, we'll just
/// provide the definitions here.
-#if TARGET_IPHONE_SIMULATOR && !defined(LC_ENCRYPTION_INFO)
+#if TARGET_OS_SIMULATOR && !defined(LC_ENCRYPTION_INFO)
#define LC_ENCRYPTION_INFO 0x21
struct encryption_info_command {
uint32_t cmd;
@@ -152,12 +152,20 @@ static BOOL isAppEncrypted() {
}
+ (BOOL)hasEmbeddedMobileProvision {
+ #if TARGET_OS_IOS
return [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"].length > 0;
+ #elif TARGET_OS_OSX
+ return NO;
+ #endif
}
+ (BOOL)isSimulator {
+ #if TARGET_OS_IOS
NSString *platform = [FIRAppEnvironmentUtil deviceModel];
return [platform isEqual:@"x86_64"] || [platform isEqual:@"i386"];
+ #elif TARGET_OS_OSX
+ return NO;
+ #endif
}
+ (NSString *)deviceModel {
@@ -174,15 +182,24 @@ static BOOL isAppEncrypted() {
}
+ (NSString *)systemVersion {
+ #if TARGET_OS_IOS
return [UIDevice currentDevice].systemVersion;
+ #elif TARGET_OS_OSX
+ return [NSProcessInfo processInfo].operatingSystemVersionString;
+ #endif
}
+ (BOOL)isAppExtension {
+ #if TARGET_OS_IOS
// Documented by <a href="https://goo.gl/RRB2Up">Apple</a>
BOOL appExtension = [[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"];
return appExtension;
+ #elif TARGET_OS_OSX
+ return NO;
+ #endif
}
+#if TARGET_OS_IOS
+ (UIApplication *)sharedApplication {
if ([FIRAppEnvironmentUtil isAppExtension]) {
return nil;
@@ -195,13 +212,22 @@ static BOOL isAppEncrypted() {
}
return sharedApplication;
}
+#elif TARGET_OS_OSX
++ (NSApplication *)sharedApplication {
+ return [NSApplication sharedApplication];
+}
+#endif
#pragma mark - Helper methods
+ (BOOL)hasSCInfoFolder {
+ #if TARGET_OS_IOS
NSString *bundlePath = [NSBundle mainBundle].bundlePath;
NSString *scInfoPath = [bundlePath stringByAppendingPathComponent:@"SC_Info"];
return [[NSFileManager defaultManager] fileExistsAtPath:scInfoPath];
+ #elif TARGET_OS_OSX
+ return NO;
+ #endif
}
@end
diff --git a/Firebase/Core/FIRNetworkURLSession.m b/Firebase/Core/FIRNetworkURLSession.m
index 2b17eb3..967ffe2 100644
--- a/Firebase/Core/FIRNetworkURLSession.m
+++ b/Firebase/Core/FIRNetworkURLSession.m
@@ -430,15 +430,19 @@
/// Creates a background session configuration with the session ID using the supported method.
- (NSURLSessionConfiguration *)backgroundSessionConfigWithSessionID:(NSString *)sessionID {
-#if (!TARGET_OS_IPHONE && defined(MAC_OS_X_VERSION_10_10) && \
- MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10) || \
- (TARGET_OS_IPHONE && defined(__IPHONE_8_0) && \
- __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0)
+ #if (TARGET_OS_OSX && defined(MAC_OS_X_VERSION_10_10) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10) || \
+ (TARGET_OS_IOS && defined(__IPHONE_8_0) && \
+ __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0)
+
// iOS 8/10.10 builds require the new backgroundSessionConfiguration method name.
return [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:sessionID];
-#elif (!TARGET_OS_IPHONE && defined(MAC_OS_X_VERSION_10_10) && \
- MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10) || \
- (TARGET_OS_IPHONE && defined(__IPHONE_8_0) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0)
+
+ #elif (TARGET_OS_OSX && defined(MAC_OS_X_VERSION_10_10) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10) || \
+ (TARGET_OS_IOS && defined(__IPHONE_8_0) && \
+ __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0)
+
// Do a runtime check to avoid a deprecation warning about using
// +backgroundSessionConfiguration: on iOS 8.
if ([NSURLSessionConfiguration
@@ -449,10 +453,11 @@
// Running on iOS 7/OS X 10.9.
return [NSURLSessionConfiguration backgroundSessionConfiguration:sessionID];
}
-#else
+
+ #else
// Building with an SDK earlier than iOS 8/OS X 10.10.
return [NSURLSessionConfiguration backgroundSessionConfiguration:sessionID];
-#endif
+ #endif
}
- (void)maybeRemoveTempFilesAtURL:(NSURL *)folderURL expiringTime:(NSTimeInterval)staleTime {
diff --git a/Firebase/Core/FIRReachabilityChecker.m b/Firebase/Core/FIRReachabilityChecker.m
index 66b6547..4817e4e 100644
--- a/Firebase/Core/FIRReachabilityChecker.m
+++ b/Firebase/Core/FIRReachabilityChecker.m
@@ -175,15 +175,23 @@ static NSString *const kFIRReachabilityDisconnectedStatus = @"Disconnected";
// Reachable flag is set. Check further flags.
if (!(flags & kSCNetworkReachabilityFlagsConnectionRequired)) {
// Connection required flag is not set, so we have connectivity.
+ #if TARGET_OS_IOS
status = (flags & kSCNetworkReachabilityFlagsIsWWAN) ? kFIRReachabilityViaCellular
: kFIRReachabilityViaWifi;
+ #elif TARGET_OS_OSX
+ status = kFIRReachabilityViaWifi;
+ #endif
} else if ((flags & (kSCNetworkReachabilityFlagsConnectionOnDemand |
kSCNetworkReachabilityFlagsConnectionOnTraffic)) &&
!(flags & kSCNetworkReachabilityFlagsInterventionRequired)) {
// If the connection on demand or connection on traffic flag is set, and user intervention
// is not required, we have connectivity.
+ #if TARGET_OS_IOS
status = (flags & kSCNetworkReachabilityFlagsIsWWAN) ? kFIRReachabilityViaCellular
: kFIRReachabilityViaWifi;
+ #elif TARGET_OS_OSX
+ status = kFIRReachabilityViaWifi;
+ #endif
}
}
return status;
diff --git a/Firebase/Core/FirebaseCore.podspec b/Firebase/Core/FirebaseCore.podspec
index f513367..ae2303f 100644
--- a/Firebase/Core/FirebaseCore.podspec
+++ b/Firebase/Core/FirebaseCore.podspec
@@ -20,6 +20,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
s.source = { :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/Firebase'
s.ios.deployment_target = '7.0'
+ s.osx.deployment_target = '10.10'
s.source_files = '**/*.[mh]'
s.public_header_files =
diff --git a/Firebase/Core/Private/FIRAppEnvironmentUtil.h b/Firebase/Core/Private/FIRAppEnvironmentUtil.h
index ba4696c..7ae9827 100644
--- a/Firebase/Core/Private/FIRAppEnvironmentUtil.h
+++ b/Firebase/Core/Private/FIRAppEnvironmentUtil.h
@@ -16,7 +16,11 @@
#import <Foundation/Foundation.h>
+#if TARGET_OS_IOS
#import <UIKit/UIKit.h>
+#elif TARGET_OS_OSX
+#import <AppKit/AppKit.h>
+#endif
@interface FIRAppEnvironmentUtil : NSObject
@@ -42,7 +46,12 @@
/// Indicates whether it is running inside an extension or an app.
+ (BOOL)isAppExtension;
+#if TARGET_OS_IOS
/// Returns the [UIApplication sharedApplication] if it is running on an app, not an extension.
+ (UIApplication *)sharedApplication;
+#elif TARGET_OS_OSX
+/// Returns the [NSApplication sharedApplication].
++ (NSApplication *)sharedApplication;
+#endif
@end
diff --git a/Firebase/Core/Private/FIRLogger.h b/Firebase/Core/Private/FIRLogger.h
index 2206c0a..7680e04 100644
--- a/Firebase/Core/Private/FIRLogger.h
+++ b/Firebase/Core/Private/FIRLogger.h
@@ -81,7 +81,7 @@ extern void FIRLogBasic(FIRLoggerLevel level,
NSString *message,
// On 64-bit simulators, va_list is not a pointer, so cannot be marked nullable
// See: http://stackoverflow.com/q/29095469
-#if __LP64__ && TARGET_IPHONE_SIMULATOR
+#if __LP64__ && TARGET_OS_SIMULATOR || TARGET_OS_OSX
va_list args_ptr
#else
va_list _Nullable args_ptr
diff --git a/Firebase/Database/Core/FPersistentConnection.m b/Firebase/Database/Core/FPersistentConnection.m
index 0eb1f9f..9298f6d 100644
--- a/Firebase/Database/Core/FPersistentConnection.m
+++ b/Firebase/Database/Core/FPersistentConnection.m
@@ -922,15 +922,15 @@ static void reachabilityCallback(SCNetworkReachabilityRef ref, SCNetworkReachabi
- (void) sendConnectStats {
NSMutableDictionary *stats = [NSMutableDictionary dictionary];
-#if TARGET_OS_IPHONE
+ #if TARGET_OS_IOS
if (self.config.persistenceEnabled) {
stats[@"persistence.ios.enabled"] = @1;
}
-#else // this must be OSX then
+ #elif TARGET_OS_OSX
if (self.config.persistenceEnabled) {
stats[@"persistence.osx.enabled"] = @1;
}
-#endif
+ #endif
NSString *sdkVersion = [[FIRDatabase sdkVersion] stringByReplacingOccurrencesOfString:@"." withString:@"-"];
NSString *sdkStatName = [NSString stringWithFormat:@"sdk.objc.%@", sdkVersion];
stats[sdkStatName] = @1;
diff --git a/Firebase/Database/Core/FRepo.m b/Firebase/Database/Core/FRepo.m
index 06cc253..f04d0f1 100644
--- a/Firebase/Database/Core/FRepo.m
+++ b/Firebase/Database/Core/FRepo.m
@@ -50,7 +50,7 @@
#import "FValueEventRegistration.h"
#import "FEmptyNode.h"
-#ifdef TARGET_OS_IPHONE
+#if TARGET_OS_IOS
#import <UIKit/UIKit.h>
#endif
@@ -543,7 +543,7 @@
return;
// Targetted compilation is ONLY for testing. UIKit is weak-linked in actual release build.
-#if TARGET_OS_IPHONE
+ #if TARGET_OS_IOS
// The idea is to wait until any outstanding sets get written to disk. Since the sets might still be in our
// dispatch queue, we wait for the dispatch queue to catch up and for persistence to catch up.
// This may be undesirable though. The dispatch queue might just be processing a bunch of incoming data or
@@ -563,7 +563,7 @@
FFLog(@"I-RDB038018", @"Background task completed. Queue time: %f", finishTime);
[application endBackgroundTask:bgTask];
});
-#endif
+ #endif
}
#pragma mark -
diff --git a/Firebase/Database/FirebaseDatabase.podspec b/Firebase/Database/FirebaseDatabase.podspec
index 4db371e..6c966ce 100644
--- a/Firebase/Database/FirebaseDatabase.podspec
+++ b/Firebase/Database/FirebaseDatabase.podspec
@@ -20,6 +20,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
s.source = { :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/Firebase'
s.ios.deployment_target = '7.0'
+ s.osx.deployment_target = '10.10'
s.source_files = '**/*.[mh]',
'third_party/Wrap-leveldb/APLevelDB.mm',
diff --git a/Firebase/Database/Persistence/FLevelDBStorageEngine.m b/Firebase/Database/Persistence/FLevelDBStorageEngine.m
index 4b324b8..e887c08 100644
--- a/Firebase/Database/Persistence/FLevelDBStorageEngine.m
+++ b/Firebase/Database/Persistence/FLevelDBStorageEngine.m
@@ -204,13 +204,13 @@ static NSString* trackedQueryKeysKey(NSUInteger trackedQueryId, NSString *key) {
}
+ (NSString *) firebaseDir {
-#if TARGET_OS_IPHONE
+ #if TARGET_OS_IOS
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [dirPaths objectAtIndex:0];
return [documentsDir stringByAppendingPathComponent:@"firebase"];
-#else // this must be OSX then
+ #elif TARGET_OS_OSX
return [NSHomeDirectory() stringByAppendingPathComponent:@".firebase"];
-#endif
+ #endif
}
- (APLevelDB *)createDB:(NSString *)name {
diff --git a/Firebase/Database/Realtime/FWebSocketConnection.m b/Firebase/Database/Realtime/FWebSocketConnection.m
index 52e2296..ea64795 100644
--- a/Firebase/Database/Realtime/FWebSocketConnection.m
+++ b/Firebase/Database/Realtime/FWebSocketConnection.m
@@ -22,7 +22,7 @@
#import "FStringUtilities.h"
#import "FIRDatabase_Private.h"
-#if TARGET_OS_IPHONE
+#if TARGET_OS_IOS
#import <UIKit/UIKit.h>
#endif
@@ -82,7 +82,7 @@
BOOL hasUiDeviceClass = NO;
// Targetted compilation is ONLY for testing. UIKit is weak-linked in actual release build.
- #if TARGET_OS_IPHONE
+ #if TARGET_OS_IOS
Class uiDeviceClass = NSClassFromString(@"UIDevice");
if (uiDeviceClass) {
systemVersion = [uiDeviceClass currentDevice].systemVersion;
diff --git a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m
index c2b395c..54fcf27 100644
--- a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m
+++ b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m
@@ -16,7 +16,7 @@
#import "FSRWebSocket.h"
-#if TARGET_OS_IPHONE
+#if TARGET_OS_IOS
#define HAS_ICU
#endif
@@ -26,9 +26,9 @@
#import <unicode/utf8.h>
#endif
-#if TARGET_OS_IPHONE
+#if TARGET_OS_IOS
#import <Endian.h>
-#else
+#elif TARGET_OS_OSX
#import <CoreServices/CoreServices.h>
#endif
diff --git a/Firebase/Storage/FIRStorageUtils.m b/Firebase/Storage/FIRStorageUtils.m
index e0abe0a..5c6a1fa 100644
--- a/Firebase/Storage/FIRStorageUtils.m
+++ b/Firebase/Storage/FIRStorageUtils.m
@@ -12,7 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#if TARGET_OS_IOS
#import <MobileCoreServices/MobileCoreServices.h>
+#elif TARGET_OS_OSX
+#import <CoreServices/CoreServices.h>
+#endif
#import "FIRStorageUtils.h"
@@ -118,4 +122,4 @@ NSString *const kGCSObjectAllowedCharacterSet =
return [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil];
}
-@end \ No newline at end of file
+@end
diff --git a/Firebase/Storage/FirebaseStorage.podspec b/Firebase/Storage/FirebaseStorage.podspec
index 69c6ddc..24fc2f8 100644
--- a/Firebase/Storage/FirebaseStorage.podspec
+++ b/Firebase/Storage/FirebaseStorage.podspec
@@ -20,6 +20,7 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
s.source = { :git => 'https://github.com/firebase/firebase-ios-sdk.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/Firebase'
s.ios.deployment_target = '7.0'
+ s.osx.deployment_target = '10.10'
s.source_files = '**/*.[mh]'
s.public_header_files =
@@ -35,7 +36,8 @@ Simplify your iOS development, grow your user base, and monetize more effectivel
'FIRStorageTaskSnapshot.h',
'FIRStorageUploadTask.h'
- s.framework = 'MobileCoreServices'
+ s.ios.framework = 'MobileCoreServices'
+ s.osx.framework = 'CoreServices'
# s.dependency 'FirebaseDev/Core'
s.dependency 'GTMSessionFetcher/Core', '~> 1.1'
s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' =>