This project demonstrates how to exchange data between Swift and JavaScript using WKWebView. The project includes a simple example where a Swift app sends data to JavaScript and vice versa.
- Clone the repository.
- Open the project in Xcode.
- Create a new iOS app and add a
WKWebViewto your app's main view controller. - Replace the content of your main view controller's Swift file with the content of the
ViewController.swiftfile provided in this repository. - Add the
index.htmlfile to your app's bundle. - Build and run the app on an iOS simulator or device.
- Interact with the app to see data exchange between Swift and JavaScript in action.
ViewController.swift: Contains the Swift code for setting up a WKWebView, loading the HTML file, and handling data exchange with JavaScript.index.html: Contains the HTML and JavaScript code for sending and receiving data to/from Swift.