forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBundleUtil.m
More file actions
38 lines (34 loc) · 1.38 KB
/
BundleUtil.m
File metadata and controls
38 lines (34 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// BundleUtil.m
// APIExample
//
// Created by zhaoyongqiang on 2022/10/25.
// Copyright © 2022 Agora Corp. All rights reserved.
//
#import "BundleUtil.h"
@implementation BundleUtil
+ (NSBundle*)bundleWithBundleName:(NSString *)bundleName podName:(NSString *)podName {
if(bundleName == nil && podName == nil) {
return nil;
} else if (bundleName == nil) {
bundleName = podName;
} else if (podName == nil) {
podName = bundleName;
}
if([bundleName containsString:@".bundle"]){
bundleName=[bundleName componentsSeparatedByString:@".bundle"].firstObject;
}
//没使用framwork的情况下
NSURL *associateBundleURL = [[NSBundle mainBundle]URLForResource:bundleName withExtension:@"bundle"];
//使用framework形式
if (!associateBundleURL) {
associateBundleURL = [[NSBundle mainBundle]URLForResource: @"Frameworks" withExtension:nil];
associateBundleURL = [associateBundleURL URLByAppendingPathComponent:podName];
// associateBundleURL = [associateBundleURL URLByAppendingPathExtension:@"framework"];
NSBundle *associateBunle = [NSBundle bundleWithURL:associateBundleURL];
associateBundleURL = [associateBunle URLForResource:bundleName withExtension:@"bundle"];
}
//生产环境直接返回空
return associateBundleURL ? [NSBundle bundleWithURL:associateBundleURL]: nil;
}
@end