Bulls-Eye-Tutorial: Chapter 7 - Testing after adding Webview
If I click to get to the AboutScreen get the Error:
fatal error: unexpectedly found nil while unwrapping an Optional value
2017-10-30 13:45:19.645864+0100 Bulleye-Tutorial[40141:4016474] fatal error: unexpectedly found nil while unwrapping an Optional value
My step 1:
to exclude typos I replaced my code with the provided code - but no difference.
I think that the error means that the ressoucre bullseye.html is not found in the specified location.
My step 2:
So I double-checked that the ressource is imported. Comparing my version with the provided project shows no differences in the location of bullseye.html.
My step 3:
Run the provided projekt (chapter-07-final)
-now it compiles without error
but: The Webview shows just white - no text, it displays nothing
Any ideas? At least the provided project should show something?
It does indeed look as if the code is not loading the HTML file properly. One possibility is that while the file was added to the project, it is not marked as being part of the correct target. With the BullsEye.html file selected, can you please check the File inspector to see that the BullsEye target is checked under the Target Membership section?
I just checked the final project for the book and it appears that it to is missing the correct target membership. I could have sworn I tested this while writing the book but obviously, something went amiss Sorry about that.
After checking the target in the provided project it now shows the html - so I have a base to continue.
In my project the target was checked. It seems there is something corrupt in my project file - I will start from chapter 6 again and see if it works - I will report back if the problem persists.
Glad to hear that you were at least able to get the base project working. If you still continue to experience issues with your own project, if you can ZIP it up and upload it somewhere like DropBox and provide a link here, I can take a look and see what is going on.
Will take a look as soon as I can. Unfortunately, had to hand my MacBook over to Apple due to hardware issues yesterday and so need to wait till it is repaired. So might take about a week (according to their estimates). Just letting you know - but will take a look and get back to you once I have the machine back.
In the mean time, if you want to debug the issue on your own, what you’d need to do would be to check if the line loading the data from the HTML file returns nil. If it does, then you know the issue is with reading the HTML file as data, if not, then the issue is elsewhere.
If the data is nil, then you need to figure out why it is nil. You can always check the final app, if you can find it in the simulator folder structure, to see if it contains the HTML file or if it is being missed out for some reason as a first step.
I’m happy to hear that you were able to sort out the issue on your own - if you hit a nil isues it’s generally either something not initializiatin properly or a connection which was not set up
When I built the Bull’s Eye Final App using the provided Source Code, the Info button would not properly load the BullsEye.html file. The quick fix for me was to delete the BullsEye.html file from the project and then re-add the file by dragging it from the source to the project. Rebuild. Run.
I just tested and you are right. It appears that the BullsEye.html file is not included in the BullsEye target. Rather than removing the file from the project and re-adding it, you can also simply select the file, switch to the File inspector and check the box for the BullsEye target. It will show up correctly then.