-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathIMGLYCamera-Bundle+.swift
More file actions
28 lines (24 loc) · 1.06 KB
/
IMGLYCamera-Bundle+.swift
File metadata and controls
28 lines (24 loc) · 1.06 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
import Foundation
extension Bundle {
private final class CurrentBundleFinder {}
static let module: Bundle = {
// If the app is built using static CocoaPods the resource bundle will be in the app's main bundle.
if
let assetBundleURL = Bundle.main.url(forResource: "IMGLYCameraAssets", withExtension: "bundle"),
let resourceBundle = Bundle(url: assetBundleURL) {
return resourceBundle
}
// If the app is built using dynamic CocoaPods the resource bundle will be embedded in the framework's bundle.
let frameworkBundle = Bundle(for: CurrentBundleFinder.self)
// Derive the bundle name for CocoaPods.
let bundleName = frameworkBundle.bundleURL.deletingPathExtension().lastPathComponent + "Assets"
// If specific asset bundle exists use this otherwise fall back to framework bundle.
if
let resourceBundleURL = frameworkBundle.url(forResource: bundleName, withExtension: "bundle"),
let resourceBundle = Bundle(url: resourceBundleURL) {
return resourceBundle
} else {
return frameworkBundle
}
}()
}