Skip to content

Commit 0e6c537

Browse files
committed
FirebaseUI 0.3.2, adds support for multiple auth subspecs (/Facebook, /Google, /Twitter, /Password)
1 parent 610fafd commit 0e6c537

File tree

9 files changed

+150
-32
lines changed

9 files changed

+150
-32
lines changed

FirebaseUI.podspec

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,61 @@
11
Pod::Spec.new do |s|
22
s.name = "FirebaseUI"
3-
s.version = "0.3.1"
3+
s.version = "0.3.2"
44
s.summary = "UI binding libraries for Firebase."
55
s.homepage = "https://github.com/firebase/FirebaseUI-iOS"
66
s.license = { :type => 'MIT', :file => 'LICENSE' }
77
s.author = { "Firebase" => "[email protected]" }
88
s.social_media_url = "https://twitter.com/firebase"
9-
s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.1' }
9+
s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.2' }
1010
s.platform = :ios
1111
s.ios.deployment_target = "8.0"
1212
s.dependency "Firebase", "~>2.2"
1313
s.ios.framework = "UIKit"
1414
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Firebase"' }
1515
s.requires_arc = true
16+
s.default_subspecs = 'Core', 'Auth'
1617

1718
s.subspec 'Core' do |core|
1819
core.source_files = "FirebaseUI/{Core,Util}/**/*.{h,m}"
1920
end
2021

2122
s.subspec 'Auth' do |auth|
22-
auth.source_files = "FirebaseUI/Auth/**/*.{h,m}"
23-
auth.resources = "FirebaseUI/Auth/Resources/*"
24-
auth.dependency "FBSDKCoreKit"
25-
auth.dependency "FBSDKLoginKit"
26-
auth.dependency "Google/SignIn"
27-
auth.ios.framework = "Accounts"
23+
auth.dependency "FirebaseUI/Facebook"
24+
auth.dependency "FirebaseUI/Google"
25+
auth.dependency "FirebaseUI/Twitter"
26+
auth.dependency "FirebaseUI/Password"
2827
end
29-
end
28+
29+
s.subspec 'AuthHelper' do |helper|
30+
helper.source_files = "FirebaseUI/Auth/**/{FirebaseAppDelegate,FirebaseLoginViewController,FirebaseAuthConstants,FirebaseAuthDelegate,FirebaseAuthProvider,FirebaseLoginButton}.{h,m}"
31+
helper.resources = "FirebaseUI/Auth/Resources/*"
32+
end
33+
34+
s.subspec 'Facebook' do |facebook|
35+
facebook.source_files = "FirebaseUI/Auth/**/FirebaseFacebookAuthProvider.{h,m}"
36+
facebook.dependency "FirebaseUI/AuthHelper"
37+
facebook.dependency "FBSDKCoreKit"
38+
facebook.dependency "FBSDKLoginKit"
39+
facebook.xcconfig = {"OTHER_CFLAGS" => "-DFIREBASEUI_ENABLE_FACEBOOK_AUTH=1"}
40+
end
41+
42+
s.subspec 'Google' do |google|
43+
google.source_files = "FirebaseUI/Auth/**/FirebaseGoogleAuthProvider.{h,m}"
44+
google.dependency "FirebaseUI/AuthHelper"
45+
google.dependency "Google/SignIn"
46+
google.xcconfig = {"OTHER_CFLAGS" => "-DFIREBASEUI_ENABLE_GOOGLE_AUTH=1 -DLOCAL_BUILD=0"}
47+
end
48+
49+
s.subspec 'Twitter' do |twitter|
50+
twitter.source_files = "FirebaseUI/Auth/**/{FirebaseTwitterAuthProvider,TwitterAuthDelegate}.{h,m}"
51+
twitter.dependency "FirebaseUI/AuthHelper"
52+
twitter.ios.framework = "Accounts"
53+
twitter.xcconfig = {"OTHER_CFLAGS" => "-DFIREBASEUI_ENABLE_TWITTER_AUTH=1"}
54+
end
55+
56+
s.subspec 'Password' do |password|
57+
password.source_files = "FirebaseUI/Auth/**/FirebasePasswordAuthProvider.{h,m}"
58+
password.dependency "FirebaseUI/AuthHelper"
59+
password.xcconfig = {"OTHER_CFLAGS" => "-DFIREBASEUI_ENABLE_PASSWORD_AUTH=1"}
60+
end
61+
end

FirebaseUI.xcodeproj/project.pbxproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@
546546
GCC_PREPROCESSOR_DEFINITIONS = (
547547
"DEBUG=1",
548548
"$(inherited)",
549+
"LOCAL_BUILD=1",
549550
);
550551
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
551552
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
@@ -614,10 +615,7 @@
614615
"$(PROJECT_DIR)/target/Products/Release-iphonesimulator",
615616
"$(PROJECT_DIR)/sdk/google_signin_sdk_2_2_0",
616617
);
617-
GCC_PREPROCESSOR_DEFINITIONS = (
618-
"LOCAL_BUILD=1",
619-
"$(inherited)",
620-
);
618+
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
621619
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
622620
GCC_WARN_PEDANTIC = YES;
623621
IPHONEOS_DEPLOYMENT_TARGET = 7.1;

FirebaseUI/Auth/API/FirebaseAppDelegate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,25 @@
2828
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
// clang-format on
32+
3133
#import <UIKit/UIKit.h>
3234

3335
#import <Firebase/Firebase.h>
3436

37+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
3538
#if LOCAL_BUILD
3639
#import <GoogleSignIn/GoogleSignIn.h>
3740
#import "GGLContext.h"
3841
#else
3942
#import <Google/SignIn.h>
4043
#endif
44+
#endif
4145

46+
#if FIREBASEUI_ENABLE_FACEBOOK_AUTH
4247
#import <FBSDKCoreKit/FBSDKCoreKit.h>
4348
#import <FBSDKLoginKit/FBSDKLoginKit.h>
49+
#endif
4450

4551
/**
4652
* A replacement for the AppDelegate which includes setup for the Google and Facebook SDK's

FirebaseUI/Auth/API/FirebaseAuthConstants.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#import <Foundation/Foundation.h>
3434
#import <CoreGraphics/CGBase.h>
3535

36-
#ifndef FirebaseAuthConstants_h
37-
#define FirebaseAuthConstants_h
38-
3936
FOUNDATION_EXPORT NSString *const kTwitterApiKey;
4037

4138
FOUNDATION_EXPORT NSString *const kFacebookAppId;
@@ -63,6 +60,4 @@ typedef NS_ENUM(NSInteger, FAuthProvider) {
6360
FAuthProviderGoogle,
6461
FAuthProviderTwitter,
6562
FAuthProviderPassword
66-
};
67-
68-
#endif /* FirebaseAuthConstants_h */
63+
};

FirebaseUI/Auth/API/FirebaseLoginViewController.h

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,39 @@
3535

3636
#import <Firebase/Firebase.h>
3737

38+
// Shared auth
39+
#import "FirebaseAuthDelegate.h"
40+
#import "FirebaseLoginButton.h"
41+
#import "FirebaseAuthProvider.h"
42+
43+
// Pull in Twitter
44+
#if FIREBASEUI_ENABLE_TWITTER_AUTH
45+
#import "FirebaseTwitterAuthProvider.h"
46+
#endif
47+
48+
// Pull in Facebook
49+
#if FIREBASEUI_ENABLE_FACEBOOK_AUTH
50+
#import "FirebaseFacebookAuthProvider.h"
51+
#endif
52+
53+
// Pull in Google
54+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
55+
#import "FirebaseGoogleAuthProvider.h"
56+
#endif
57+
58+
// Google local build issues
59+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
3860
#if LOCAL_BUILD
3961
#import <GoogleSignIn/GoogleSignIn.h>
4062
#else
4163
#import <Google/SignIn.h>
4264
#endif
65+
#endif
4366

44-
#import "FirebaseAuthDelegate.h"
45-
#import "FirebaseTwitterAuthProvider.h"
46-
#import "FirebaseFacebookAuthProvider.h"
47-
#import "FirebaseGoogleAuthProvider.h"
67+
// Pull in Password
68+
#if FIREBASEUI_ENABLE_PASSWORD_AUTH
4869
#import "FirebasePasswordAuthProvider.h"
49-
#import "FirebaseLoginButton.h"
70+
#endif
5071

5172
/**
5273
* FirebaseLoginViewController is a subclass of UIViewController that provides a
@@ -55,8 +76,19 @@
5576
* error handling.
5677
* This also serves as a template for developers interested in developing custom login UI.
5778
*/
79+
#if FIREBASEUI_ENABLE_TWITTER_AUTH && FIREBASEUI_ENABLE_GOOGLE_AUTH
5880
@interface FirebaseLoginViewController
5981
: UIViewController<FirebaseAuthDelegate, TwitterAuthDelegate, GIDSignInUIDelegate>
82+
#elif FIREBASEUI_ENABLE_TWITTER_AUTH
83+
@interface FirebaseLoginViewController
84+
: UIViewController<FirebaseAuthDelegate, TwitterAuthDelegate>
85+
#elif FIREBASEUI_ENABLE_GOOGLE_AUTH
86+
@interface FirebaseLoginViewController
87+
: UIViewController<FirebaseAuthDelegate, GIDSignInUIDelegate>
88+
#else
89+
@interface FirebaseLoginViewController: UIViewController<FirebaseAuthDelegate>
90+
#endif
91+
6092

6193
/**
6294
* Container view for login activity which wraps the header text and cancel button.
@@ -128,28 +160,45 @@
128160
* requests against the Twitter API and uses the response to authenticate
129161
* against the Firebase database.
130162
*/
163+
#if FIREBASEUI_ENABLE_TWITTER_AUTH
131164
@property(strong, nonatomic) FirebaseTwitterAuthProvider *twitterAuthProvider;
165+
#else
166+
@property(strong, nonatomic) FirebaseAuthProvider *twitterAuthProvider;
167+
#endif
132168

133169
/**
134170
* The provider object for Facebook Authentication. This object handles the
135171
* requests against the Facebook SDK and uses the response to authenticate
136172
* against the Firebase database.
137173
*/
174+
#if FIREBASEUI_ENABLE_FACEBOOK_AUTH
138175
@property(strong, nonatomic) FirebaseFacebookAuthProvider *facebookAuthProvider;
176+
#else
177+
@property(strong, nonatomic) FirebaseAuthProvider *facebookAuthProvider;
178+
#endif
179+
139180

140181
/**
141182
* The provider object for Google Authentication. This object handles the
142183
* requests against the Google SDK and uses the response to authenticate
143184
* against the Firebase database.
144185
*/
186+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
145187
@property(strong, nonatomic) FirebaseGoogleAuthProvider *googleAuthProvider;
188+
#else
189+
@property(strong, nonatomic) FirebaseAuthProvider *googleAuthProvider;
190+
#endif
146191

147192
/**
148193
* The provider object for Email/Password Authentication. This object handles the
149194
* requests to the Firebase user authentication system to authenticate users to
150195
* the Firebase database.
151196
*/
197+
#if FIREBASEUI_ENABLE_PASSWORD_AUTH
152198
@property(strong, nonatomic) FirebasePasswordAuthProvider *passwordAuthProvider;
199+
#else
200+
@property(strong, nonatomic) FirebaseAuthProvider *passwordAuthProvider;
201+
#endif
153202

154203
/**
155204
* Create an instance of FirebaseLoginViewController, which allows for easy authentication to

FirebaseUI/Auth/Implementation/FirebaseAppDelegate.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,43 @@
3333
@implementation FirebaseAppDelegate
3434

3535
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
36+
37+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
3638
// Configure Google
3739
NSError* configureError;
3840
[[GGLContext sharedInstance] configureWithError: &configureError];
41+
#endif
3942

43+
#if FIREBASEUI_ENABLE_FACEBOOK_AUTH
4044
// Configure Facebook
4145
[[FBSDKApplicationDelegate sharedInstance] application:application
4246
didFinishLaunchingWithOptions:launchOptions];
47+
#endif
4348

4449
// Return successful app launch
4550
return YES;
4651
}
4752

4853
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
4954
// This is the Facebook or Google SDK returning to the app after authentication.
55+
56+
#if FIREBASEUI_ENABLE_FACEBOOK_AUTH
5057
if ([url.scheme hasPrefix:@"fb"]) {
5158
return [[FBSDKApplicationDelegate sharedInstance] application:application
5259
openURL:url
5360
sourceApplication:sourceApplication
5461
annotation:annotation];
55-
} else if ([url.scheme hasPrefix:@"com.google"]) {
62+
}
63+
#endif
64+
65+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
66+
if ([url.scheme hasPrefix:@"com.google"]) {
5667
return [[GIDSignIn sharedInstance] handleURL:url
5768
sourceApplication:sourceApplication
5869
annotation:annotation];
5970
}
71+
#endif
72+
6073
return YES;
6174
}
6275

FirebaseUI/Auth/Implementation/FirebaseLoginViewController.m

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,17 @@ - (void)viewDidLoad {
132132

133133
- (instancetype)enableProvider:(FAuthProvider)provider {
134134
switch (provider) {
135+
#if FIREBASEUI_ENABLE_FACEBOOK_AUTH
135136
case FAuthProviderFacebook:
136137
if (!self.facebookAuthProvider) {
137138
self.facebookAuthProvider =
138139
[[FirebaseFacebookAuthProvider alloc] initWithRef:self.ref authDelegate:self];
139140
[_socialProviders addObject:self.facebookAuthProvider];
140141
}
141142
break;
143+
#endif
142144

145+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
143146
case FAuthProviderGoogle:
144147
if (!self.googleAuthProvider) {
145148
self.googleAuthProvider = [[FirebaseGoogleAuthProvider alloc] initWithRef:self.ref
@@ -148,7 +151,9 @@ - (instancetype)enableProvider:(FAuthProvider)provider {
148151
[_socialProviders addObject:self.googleAuthProvider];
149152
}
150153
break;
154+
#endif
151155

156+
#if FIREBASEUI_ENABLE_TWITTER_AUTH
152157
case FAuthProviderTwitter:
153158
if (!self.twitterAuthProvider) {
154159
self.twitterAuthProvider = [[FirebaseTwitterAuthProvider alloc] initWithRef:self.ref
@@ -157,13 +162,16 @@ - (instancetype)enableProvider:(FAuthProvider)provider {
157162
[_socialProviders addObject:self.twitterAuthProvider];
158163
}
159164
break;
165+
#endif
160166

167+
#if FIREBASEUI_ENABLE_PASSWORD_AUTH
161168
case FAuthProviderPassword:
162169
if (!self.passwordAuthProvider) {
163170
self.passwordAuthProvider =
164171
[[FirebasePasswordAuthProvider alloc] initWithRef:self.ref authDelegate:self];
165172
}
166173
break;
174+
#endif
167175

168176
default:
169177
[NSException raise:NSInternalInconsistencyException
@@ -181,22 +189,30 @@ - (void)loginButtonPressed:(id)button {
181189
if ([button isKindOfClass:[FirebaseLoginButton class]]) {
182190
FirebaseLoginButton *loginButton = (FirebaseLoginButton *)button;
183191
switch (loginButton.provider) {
192+
#if FIREBASEUI_ENABLE_FACEBOOK_AUTH
184193
case FAuthProviderFacebook:
185194
[self.facebookAuthProvider login];
186195
break;
196+
#endif
187197

198+
#if FIREBASEUI_ENABLE_GOOGLE_AUTH
188199
case FAuthProviderGoogle:
189200
[self.googleAuthProvider login];
190201
break;
202+
#endif
191203

204+
#if FIREBASEUI_ENABLE_TWITTER_AUTH
192205
case FAuthProviderTwitter:
193206
[self.twitterAuthProvider login];
194207
break;
208+
#endif
195209

210+
#if FIREBASEUI_ENABLE_PASSWORD_AUTH
196211
case FAuthProviderPassword:
197212
[self.passwordAuthProvider loginWithEmail:self.emailTextField.text
198213
andPassword:self.passwordTextField.text];
199214
break;
215+
#endif
200216

201217
default:
202218
[NSException raise:NSInternalInconsistencyException
@@ -229,7 +245,6 @@ - (void)dismissViewControllerWithUser:(FAuthData *)user andError:(NSError *)erro
229245

230246
#pragma mark -
231247
#pragma mark Firebase Auth Delegate methods
232-
233248
- (void)authProvider:(id)provider onLogin:(FAuthData *)authData {
234249
_selectedAuthProvider = provider;
235250
self.emailTextField.text = @"";
@@ -272,7 +287,7 @@ - (void)onLogout {
272287

273288
#pragma mark -
274289
#pragma mark Twitter Auth Delegate methods
275-
290+
#if FIREBASEUI_ENABLE_TWITTER_AUTH
276291
- (void)createTwitterAccount {
277292
[[UIApplication sharedApplication]
278293
openURL:[NSURL URLWithString:@"https://www.twitter.com/signup"]];
@@ -304,5 +319,6 @@ - (void)selectTwitterAccount:(NSArray *)accounts {
304319

305320
[self presentViewController:accountSelectController animated:YES completion:nil];
306321
}
322+
#endif
307323

308324
@end

0 commit comments

Comments
 (0)