1 // Copyright 2017 Google
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #import "Private/FIRBundleUtil.h"
17 @implementation FIRBundleUtil
19 + (NSArray *)relevantBundles {
20 return @[ [NSBundle mainBundle], [NSBundle bundleForClass:[self class]] ];
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.
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"]];
48 + (BOOL)hasBundleIdentifier:(NSString *)bundleIdentifier inBundles:(NSArray *)bundles {
49 for (NSBundle *bundle in bundles) {
50 if ([bundle.bundleIdentifier isEqualToString:bundleIdentifier]) {