I'm trying to load and execute a WebAssembly .wasm from within a Swift-based, iOS app. I first attempted to use the JavaScriptCore Framework but the WebAssembly.* module wasn't available in the Context when I tried to evaluate a trivial script. I was able to confirm the WebAssembly isn't defined via the Safari Debugger Console.
I then attempted to use WKWebView because I'm led to believe that the lack of WebAssembly is due to JSC not supporting JIT, which WKWebView should. I got the same result.
Here's a trivial app running on an iPhone X 12.4 emulator, Xcode 10.3 and the WebKit Framework manually added to the project. Make sure to open Safari and Select "Developer>Simulator" for WKWebView debugger.
import UIKit
import WebKit
class ViewController: UIViewController {
#IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
}
#IBAction func onClick(_ sender: UIButton) {
let testWasm = """
if(typeof WebAssembly !== 'undefined') {
console.log("Hello, Wasm.");
} else {
console.log("No Wasm for you!");
}
"""
webView.evaluateJavaScript(testWasm)
}
}
Does iOS actually have a way to load WebAssembly into a Swift-based app?
I wanted to run some benchmarks with JSC to compare it with Wasm3.
Basically I run into the same situation and wasn't able to fix so far.
Wasm3 runs perfectly fine on iOS, and may suite your needs at the moment.
Currently you can't run WebAssembly with JSC on the simulator according to this comment.
It appears that JavaScriptCore now has a WebAssembly interpreter, as of Feb 2020.
Related
I have several UIKit-based iOS apps that are already distributed on the AppStore that I would like to update, and I consider switching to SwiftUI.
My question is: what would happen for users who already own the app but are running iOS versions older than iOS13? Will the app become totally unavailable for them or will they keep the ability to use their old UIKit version?
Thank you very much !
To allow SwiftUI in your app you’ll have to allow support for iOS 13 and above. You can do so by either change the support of your app to iOS 13 and above or use ‘ #available(iOS 13.0, *)’ decorator around you new code.
In the first case users will keep their ability to use the latest version installed on their device. They won’t be able to update to newer versions.
On the later case, which will require more handling on your part, as a developer. Users will be able to continue and update the application and use the alternative code you provided
You can use compiler directives to create SwiftUI views for users running iOS 13, and provide UIKit alternatives for iOS 12 or lower.
For example, you can mark your SwiftUI view as only available from iOS 13:
#available(iOS 13.0, *)
struct MyView: View {
// ...
}
And create a UIKit alternative:
class MyViewController: UIViewController {
// ...
}
Then, when it comes to presenting the view, you can conditionally show the correct version:
let destinationVC: UIViewController
if #available(iOS 13.0, *) {
destinationVC = UIHostingController(rootView: MyView())
} else {
destinationVC = MyViewController()
}
self.present(destinationVC, animated: true, completion: nil)
I am trying to FirebaseCrashlytics in my app but stuck in 3rd step.
I am crashing app at
import UIKit
import FirebaseCrashlytics
class ViewController: UIViewController {
let testarry = [1, 3, 5]
override func viewDidLoad() {
super.viewDidLoad()
// crash app
print(testarry[5])
}
}
Run Script
Even after
Build and run your app
Stop the app from Xcode
Open the app manually from your device or simulator.
Third step is not passing
in xcode console getting output like
Is there anything i am missing?
Your upload runscript does not look correct, try following this format. Also, make sure your google services file is in your app.
I have an iOS app (create feb 2019) which is now also available for MacOS by using Mac Catalyst.
The app works fine. I added menu functionality to the File menu with
override func validate(_ command: UICommand) {
}
Now I want to remove the Help menu.
For this I used, buildmenu in AppDelegate.
override func buildMenu(with builder: UIMenuBuilder)
{
super.buildMenu(with: builder)
builder.remove(menu: .help)
}
In a newer app (Dec 2019) for Catalyst this works fine, and the code removes the menu.
In my older app, buildMenu is not called.
AppDelegate is setup as a UIResponder...
I have no idea how to make this work.
Any idea what I can try?
Best regards.
Turns out it was my mistake.
Once you add a Menu (UiMenuRoot) to the project, you can not use UIMenubuilder to modify the menu.
There are some things that CAN be done in react native but due to performance concerns, I have decided to implement in Swift and then run it in react native, for example, image processing.
Suppose I have a swift app that doesn't do anything other than displaying Hello World like so:
the code for it is not modified at all:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
I would like to run this simple app in react native in this fashion:
SimpleApp.show();
How can I make this happen?
You could do so using NativeModules
Interesting helpful article that helped me through my fitness application: Swift Modules for React Native
And this one would help too!
React Native app in Swift
Could not find information. I built pg app with 'cordova-plugin-wkwebview-engine'.
How to check if phonegap web app on ios 9.2 is really using WKWebview? Could not find info how userAgent string should look like for WKWebView.
Previous answer doesn't work on iOS 10, but you can use this code
if (window.webkit) {
//WKWebView
}
Old answer:
You can check for indexedDB
if (window.indexedDB) {
//WKWebView
}