added iOS source code
[wl-app.git] / iOS / Pods / FirebaseCore / Firebase / Core / FIRBundleUtil.m
1 // Copyright 2017 Google
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #import "Private/FIRBundleUtil.h"
16
17 @implementation FIRBundleUtil
18
19 + (NSArray *)relevantBundles {
20   return @[ [NSBundle mainBundle], [NSBundle bundleForClass:[self class]] ];
21 }
22
23 + (NSString *)optionsDictionaryPathWithResourceName:(NSString *)resourceName
24                                         andFileType:(NSString *)fileType
25                                           inBundles:(NSArray *)bundles {
26   // Loop through all bundles to find the config dict.
27   for (NSBundle *bundle in bundles) {
28     NSString *path = [bundle pathForResource:resourceName ofType:fileType];
29     // Use the first one we find.
30     if (path) {
31       return path;
32     }
33   }
34   return nil;
35 }
36
37 + (NSArray *)relevantURLSchemes {
38   NSMutableArray *result = [[NSMutableArray alloc] init];
39   for (NSBundle *bundle in [[self class] relevantBundles]) {
40     NSArray *urlTypes = [bundle objectForInfoDictionaryKey:@"CFBundleURLTypes"];
41     for (NSDictionary *urlType in urlTypes) {
42       [result addObjectsFromArray:urlType[@"CFBundleURLSchemes"]];
43     }
44   }
45   return result;
46 }
47
48 + (BOOL)hasBundleIdentifier:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles {
49   for (NSBundle *bundle in bundles) {
50     if ([bundle.bundleIdentifier isEqualToString:bundleIdentifier]) {
51       return YES;
52     }
53   }
54   return NO;
55 }
56
57 @end