Cannot convert value of type 'String?' to expected argument type 'URL'
<p>I'm trying to load data from file which was in main bundle. When I use this code</p>

<pre><code> let path = Bundle.main.path(forResource: "abc", ofType: "txt")
 let dataTwo = try! Data(contentsOf: path)\\ error here
</code></pre>

<p>Also I tried to convert String to URL </p>

<pre><code> let dataTwo = try! Data(contentsOf: URL(string: "file://\(path)")!)
</code></pre>

<p>But after execution am getting this </p>

<blockquote>
  <p>fatal error: unexpectedly found nil while unwrapping an Optional value</p>
</blockquote>