Skip to content

Commit 5feba0a

Browse files
authored
Merge pull request #587 from morganchen12/master
Fix missing icons issue
2 parents be5f36b + 96f0db4 commit 5feba0a

File tree

10 files changed

+111
-96
lines changed

10 files changed

+111
-96
lines changed

AnonymousAuth/FirebaseAnonymousAuthUI/FUIAnonymousAuth.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ - (NSString *)signInLabel {
8888
}
8989

9090
- (UIImage *)icon {
91-
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
92-
return [FUIAuthUtils imageNamed:@"ic_anonymous" fromBundle:bundle];
91+
return [FUIAuthUtils imageNamed:@"ic_anonymous" fromBundleNameOrNil:FUIAuthBundleName];
9392
}
9493

9594
- (UIColor *)buttonBackgroundColor {

Auth/FirebaseAuthUI/FUIAuthUtils.m

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,37 @@ @implementation FUIAuthUtils
2222

2323
+ (NSBundle *)bundleNamed:(NSString *)bundleName {
2424
NSBundle *frameworkBundle = nil;
25-
if (bundleName) {
26-
NSString *path = [[NSBundle mainBundle] pathForResource:bundleName ofType:@"bundle"];
27-
if (path == nil) {
28-
// Check framework resources if bundle isn't present in main bundle.
29-
path = [[NSBundle mainBundle] pathForResource:bundleName ofType:@"framework"];
30-
}
31-
frameworkBundle = [NSBundle bundleWithPath:path];
32-
} else {
25+
if (!bundleName) {
26+
bundleName = FUIAuthBundleName;
27+
}
28+
NSString *path = [[NSBundle mainBundle] pathForResource:bundleName ofType:@"bundle"];
29+
if (!path) {
30+
// Check framework resources if bundle isn't present in main bundle.
31+
path = [[NSBundle mainBundle] pathForResource:bundleName ofType:@"framework"];
32+
}
33+
frameworkBundle = [NSBundle bundleWithPath:path];
34+
if (!frameworkBundle) {
3335
frameworkBundle = [NSBundle bundleForClass:[self class]];
3436
}
3537
return frameworkBundle;
3638
}
3739

3840
+ (UIImage *)imageNamed:(NSString *)name fromBundle:(NSBundle *)bundle {
39-
if (bundle == nil) {
41+
if (!bundle) {
4042
bundle = [self bundleNamed:nil];
4143
}
4244
NSString *path = [bundle pathForResource:name ofType:@"png"];
45+
if (!path) {
46+
NSLog(@"Warning: Unable to find asset %@ in bundle %@.", name, bundle);
47+
}
4348
return [UIImage imageWithContentsOfFile:path];
4449
}
4550

4651
+ (UIImage *)imageNamed:(NSString *)name fromBundleNameOrNil:(nullable NSString *)bundleNameOrNil {
4752
NSString *path = [[FUIAuthUtils bundleNamed:bundleNameOrNil] pathForResource:name ofType:@"png"];
53+
if (!path) {
54+
NSLog(@"Warning: Unable to find asset %@ in bundle named %@.", name, bundleNameOrNil);
55+
}
4856
return [UIImage imageWithContentsOfFile:path];
4957
}
5058

EmailAuth/FirebaseEmailAuthUI/FUIEmailAuth.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ - (NSString *)signInLabel {
119119
}
120120

121121
- (UIImage *)icon {
122-
return [FUIAuthUtils imageNamed:@"ic_email" fromBundle:[NSBundle bundleForClass:[self class]]];
122+
return [FUIAuthUtils imageNamed:@"ic_email" fromBundleNameOrNil:FUIEmailAuthBundleName];
123123
}
124124

125125
- (UIColor *)buttonBackgroundColor {

EmailAuth/FirebaseEmailAuthUI/FUIPasswordSignUpViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ - (UIButton *)visibilityToggleButtonForPasswordField {
332332

333333
- (void)updateIconForRightViewButton:(UIButton *)button {
334334
NSString *imageName = _passwordField.secureTextEntry ? @"ic_visibility" : @"ic_visibility_off";
335-
UIImage *image = [FUIAuthUtils imageNamed:imageName fromBundle:[FUIAuthUtils bundleNamed:FUIAuthBundleName]];
335+
UIImage *image = [FUIAuthUtils imageNamed:imageName fromBundleNameOrNil:FUIAuthBundleName];
336336
[button setImage:image forState:UIControlStateNormal];
337337
}
338338

FacebookAuth/FirebaseFacebookAuthUI/FUIFacebookAuth.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ - (NSString *)signInLabel {
108108
}
109109

110110
- (UIImage *)icon {
111-
return [FUIAuthUtils imageNamed:@"ic_facebook" fromBundle:[NSBundle bundleForClass:[self class]]];
111+
return [FUIAuthUtils imageNamed:@"ic_facebook" fromBundleNameOrNil:kBundleName];
112112
}
113113

114114
- (UIColor *)buttonBackgroundColor {
@@ -222,7 +222,7 @@ - (void)callbackWithCredential:(nullable FIRAuthCredential *)credential
222222
@brief Validates that Facebook SDK data was filled in Info.plist and creates Facebook login manager
223223
*/
224224
- (void)configureProvider {
225-
NSBundle *bundle = [FUIAuthUtils bundleNamed:nil];
225+
NSBundle *bundle = [NSBundle mainBundle];
226226
NSString *facebookAppId = [bundle objectForInfoDictionaryKey:kFacebookAppId];
227227
NSString *facebookDisplayName = [bundle objectForInfoDictionaryKey:kFacebookDisplayName];
228228

GoogleAuth/FirebaseGoogleAuthUI/FUIGoogleAuth.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ - (NSString *)signInLabel {
9797
}
9898

9999
- (UIImage *)icon {
100-
return [FUIAuthUtils imageNamed:@"ic_google" fromBundle:[NSBundle bundleForClass:[self class]]];
100+
return [FUIAuthUtils imageNamed:@"ic_google" fromBundleNameOrNil:kBundleName];
101101
}
102102

103103
- (UIColor *)buttonBackgroundColor {

PhoneAuth/FirebasePhoneAuthUI/FUIPhoneAuth.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ - (NSString *)signInLabel {
102102
}
103103

104104
- (UIImage *)icon {
105-
return [FUIAuthUtils imageNamed:@"ic_phone" fromBundle:[NSBundle bundleForClass:[self class]]];
105+
return [FUIAuthUtils imageNamed:@"ic_phone" fromBundleNameOrNil:FUIPhoneAuthBundleName];
106106
}
107107

108108
- (UIColor *)buttonBackgroundColor {

TwitterAuth/FirebaseTwitterAuthUI/FUITwitterAuth.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ - (NSString *)signInLabel {
7474
}
7575

7676
- (UIImage *)icon {
77-
return [FUIAuthUtils imageNamed:@"ic_twitter" fromBundle:[NSBundle bundleForClass:[self class]]];
77+
return [FUIAuthUtils imageNamed:@"ic_twitter" fromBundleNameOrNil:kBundleName];
7878
}
7979

8080
- (UIColor *)buttonBackgroundColor {

samples/swift/FirebaseUI-demo-swift.xcodeproj/project.pbxproj

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@
332332
isa = PBXProject;
333333
attributes = {
334334
LastSwiftUpdateCheck = 0730;
335-
LastUpgradeCheck = 0800;
335+
LastUpgradeCheck = 1010;
336336
ORGANIZATIONNAME = "Firebase, Inc.";
337337
TargetAttributes = {
338338
8DABC9841D3D82D600453807 = {
@@ -632,14 +632,22 @@
632632
CLANG_CXX_LIBRARY = "libc++";
633633
CLANG_ENABLE_MODULES = YES;
634634
CLANG_ENABLE_OBJC_ARC = YES;
635+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
635636
CLANG_WARN_BOOL_CONVERSION = YES;
637+
CLANG_WARN_COMMA = YES;
636638
CLANG_WARN_CONSTANT_CONVERSION = YES;
639+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
637640
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
638641
CLANG_WARN_EMPTY_BODY = YES;
639642
CLANG_WARN_ENUM_CONVERSION = YES;
640643
CLANG_WARN_INFINITE_RECURSION = YES;
641644
CLANG_WARN_INT_CONVERSION = YES;
645+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
646+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
647+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
642648
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
649+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
650+
CLANG_WARN_STRICT_PROTOTYPES = YES;
643651
CLANG_WARN_SUSPICIOUS_MOVE = YES;
644652
CLANG_WARN_UNREACHABLE_CODE = YES;
645653
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -682,14 +690,22 @@
682690
CLANG_CXX_LIBRARY = "libc++";
683691
CLANG_ENABLE_MODULES = YES;
684692
CLANG_ENABLE_OBJC_ARC = YES;
693+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
685694
CLANG_WARN_BOOL_CONVERSION = YES;
695+
CLANG_WARN_COMMA = YES;
686696
CLANG_WARN_CONSTANT_CONVERSION = YES;
697+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
687698
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
688699
CLANG_WARN_EMPTY_BODY = YES;
689700
CLANG_WARN_ENUM_CONVERSION = YES;
690701
CLANG_WARN_INFINITE_RECURSION = YES;
691702
CLANG_WARN_INT_CONVERSION = YES;
703+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
704+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
705+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
692706
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
707+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
708+
CLANG_WARN_STRICT_PROTOTYPES = YES;
693709
CLANG_WARN_SUSPICIOUS_MOVE = YES;
694710
CLANG_WARN_UNREACHABLE_CODE = YES;
695711
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;

0 commit comments

Comments
 (0)