2

I'm trying to open SFSafariViewController with local html but it causes crash.

let vc = SFSafariViewController(url: URL(fileURLWithPath: Bundle.main.path(forResource: "untitled", ofType: "html")!))
vc.delegate = self

self.present(vc, animated: true)

Is there a way to do it? I can see file path when i debugged.

...../Devices/4980A022-975B-47D3-991B-C9741B06A5FB/data/Containers/Bundle/Application/22BFED43-49B2-4EB9-BAC3-BED26440BA52/xxxx-Internal.app/untitled.html

Sailendra
  • 1,318
  • 14
  • 29
erdikanik
  • 674
  • 9
  • 11
  • Try checking scheme of URL before making an instance of SFSafariViewController, else it will crash. It only supported HTTP & HTTP urls – Sailendra Nov 27 '19 at 08:21
  • As @SailendraKumarDhal says, the URL must be a `http` or `https` as mentioned here: https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/1621222-init. See also this fine answer: https://stackoverflow.com/a/39869386/4063602 – pbodsk Nov 27 '19 at 08:25
  • Yes, WKWebView is the alternate one... – Sailendra Nov 27 '19 at 08:34

0 Answers0