Learn Courses My Dashboard

Not finding json(again)

I thought I had established how to use a json file in an app bundle, but seemed to get lost. I moved my project along but then it got so messed up I decided to start over. As seen in the two images, the project is mostly built from M6L12, with the json capture from M2L12. I created the Data folder and made sure to copy the json file when moving it. I then renamed the json file to data.json within Xcode.

The json has target membership checked

What else can go wrong with this process that I should check?
Thanks, Mark

I’m curious why you are searching for a path in the Bundle and then converting it to a URL instead of just searching for the URL directly.

if let url = Bundle.main.url(forResource: "data", withExtension: "json") {
    //do whatever you gonna do

I’m curious and I wonder if it would make a difference.

Also, this:

I’ve found Xcode sometimes gets confused when you rename files or move them around into/out of folders, etc. Try cleaning your build folder, then restart Xcode.