Group Group Group Group Group Group Group Group Group

iOS 11 & Swift 4 tutorial, about screen url not loading

#1

Running thru the tutorials, we get to the part where the about screen is converted to use .html.

The if let url = Bundle.main.url(forResource: “BullsEye”, withExtension: “html”) {
fails to load.

I was looking for a version of the function that would return an error code, didn’t see one.

I’d at least like to know the error code if I were to put this into production. My guess is that my bundle layout is somehow different.

I’m wondering if there’s a safer way of doing this and if any else has had a problem with this.

The file is “BullsEye.html”. I can see it listed in the file browser, but don’t really know where the function is looking to find it. It shows up in finder with all the other files. I can’t see anything else being different.

Thanks for any insight.

#2

Hi Karljay,

Which book are you in? There is no conversion to html in iOS 11 by Tutorials and I want to make sure the correct authors see this.

#3

https://www.raywenderlich.com/173650/raywenderlich-com-ios-11-swift-4-beginners-course-now-udemy

It’s the “bullseye” project and I found a solution to one problem. The about screen was converted to use the “BullsEye.html” file but it doesn’t load onto the device unless you change the build phase “Copy Bundle Resources” and add the file.

It doesn’t work in the Sim, don’t know why. I tried to do a file listing, but everything’s changed for Swift 4 and I haven’t done a new file listing to array thing in Swift 4 yet. I’ve done it in ObjC, but can’t seem to find a Swift 4 version.

The code should return an error (that’s probably in a future version).

So it works on the test device if you add the file to the copy bundle settings, it doesn’t work on the Sim and no error is returned (errors are probably handled later in the book).

#4

Ah, ok. You posted this in the area for the book iOS 11 by Tutorials, which is why I don’t recognize the problem. I’ll see if I can’t get someone to respond.

#5

Hey! I tried out the materials for video 42, and I was able to view the HTML file in the Simulator. Ray says at 1:05 to make sure “Copy items if needed” is selected; perhaps missing that step was a source of your problem?

As for handling code problems with not having the file present, I recommend diving into the videos on Optionals in Ray’s Programming in Swift section.

closed #6

This topic was automatically closed after 166 days. New replies are no longer allowed.