Skip to content

Commit dc1602a

Browse files
committed
Fix for if user manually integrated framework
1 parent 2def119 commit dc1602a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

EmbedFramework/AdaWebHostViewController.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,19 @@ import WebKit
1212
class AdaWebHostViewController: UIViewController {
1313
static func createWebController(with webView: WKWebView) -> AdaWebHostViewController {
1414
let bundle = Bundle(for: AdaWebHostViewController.self)
15-
let frameworkBundlePath = bundle.path(forResource: "AdaEmbedFramework", ofType: "bundle")!
16-
let frameworkBundle = Bundle(path: frameworkBundlePath)
17-
let storyboard = UIStoryboard(name: "AdaWebHostViewController", bundle: frameworkBundle)
15+
16+
var storyboard:UIStoryboard
17+
18+
// Loads the resource_bundle if available (Cocoapod)
19+
if (bundle.path(forResource: "AdaEmbedFramework", ofType: "bundle") != nil){
20+
let frameworkBundlePath = bundle.path(forResource: "AdaEmbedFramework", ofType: "bundle")!
21+
let frameworkBundle = Bundle(path: frameworkBundlePath)
22+
storyboard = UIStoryboard(name: "AdaWebHostViewController", bundle: frameworkBundle)
23+
} else {
24+
// Used for if SDK was manually imported
25+
storyboard = UIStoryboard(name: "AdaWebHostViewController", bundle: bundle)
26+
}
27+
1828
guard let viewController = storyboard.instantiateInitialViewController() as? AdaWebHostViewController else { fatalError("This should never, ever happen.") }
1929
viewController.webView = webView
2030
return viewController

0 commit comments

Comments
 (0)