It depends.
For most things where you are doing something like small games or children’s books that become apps this is a great way to work in an intuitive program and then make it into a native app.
I would say anything that can function on the web without a helper but would make a nice app then give it a try.
But if you want the functionality of Core Location services and Core Data from iOS it is best to work in Swift right from the start.
Yes and no.
When I tried it at first it was having trouble working with local embedded HTML 5 files.
They would not link properly and I kept getting errors.
I have seen some work arounds for it and they are definitely more complex than the UIWebview
The benefit of WKWebView for linking to online content seems to be where the big lift is.
I am not sure it will give your hybrid app any extra benefits. Or rather I do not think your UIWebView will make your app suffer.
However, Here is one work around I found.
The key is for the BaseUrl which replaces the localfilePath
import UIKit
import WebKit
class ViewController: UIViewController { @IBOutlet var containerView: UIView! = nil //allows the class to refrence WKWebView
var webView: WKWebView?
Thanks, Nick, I appreciate your time. I’ve kind of been pulling my hair out over this. Documentation is trying to push folk from UIWebView to WK WebView, so I thought I’d give it a try. But, while webview is fairly straightforward, WKWebView, as you’ve mentioned, is much less so.
With your code, for the baseUrl, I’m unclear how to write the string. Say I have a folder, called Project, that I’ve copied into my xcode. Inside Project is my project.html file and its resource folder, called Folder. How would I define the string? I seem to be labeling things incorrectly because it’s still not seeing the resources.
Hmm.. I have not seen this issue and have used wkwebview in the past with no issues
I just did a convert on the project to use modernised swift syntax and update to modern Xcode.
Apart from Xcode throwing up some errors about some notifications syntax. Which can be ignored , just rerun build and they go away Xcode seems to jst want me to wast my time writing the line again.
All still works .
Thanks. In this, I’m looking for an alternative for #selector(enterBackground), as my Xcode is not liking the enterBackground. Swift keeps changing, which I guess is a good thing/frustrating thing.
Thanks for the insight Mark!
I will give this a go tonight and prepare another addendum to the video tutorials.
I have been working off and on with the Android version as well as prototyping templates for iOS and Android in Hype…now that I understand how to load SanFrancisco fonts
Thanks @Daniel !
Wow, thanks, Mark. You’ve made use of the evaluateJavaScript thing, here. I had been looking at that, thinking it might make sense, but wasn’t sure how to implement it. And you have created an enterBackground function. For some reason when I had tried that, I ended up with a new error. Going to have to recheck my typing.
Thanks again!
This really is one of the best forums, due in great part to folk like you both.
I don’t know if anyone else already encountered this problem, so here I go.
Until now everything worked smoothly and I’d like to thank @nick for his excellent tutorial. But we have Xcode 9 now and my earlier projects don’t work anymore because of: Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). This warning comes after the line: let myRequest = NSURLRequest(url: localfilePath!);
and also: fatal error: unexpectedly found nil while unwrapping an Optional value
I can’t seem to fix it. Do you have a solution?
you still forgot the html files. But I just added my own.
I suspect that the issue is that the html index.html and the hyperesources folder have not been added to the ‘Copy Bundle Resources’ in the build phase for the project.
Sorry, I don’t get it. I have done it this way for some time now and all over sudden it stops working. I already have a test version off the app in the App Store. Here is a screenshot of the ‘error’. And where would I find "Copy Bundle Resources’?