Cannot find 'ContentView' in scope. in Xcode 14

Hi,

I am trying to create web app for iOS like an app of my website when someone open a app its shows my website.

I am using code give by app developer website web view code:

code in content view.swift file

import UIKit
import WebKit

class ViewController: UIViewController, WKUIDelegate {
    
    var webView: WKWebView!
     override func loadView() {
      let webConfiguration = WKWebViewConfiguration()
      webView = WKWebView(frame: .zero, configuration: webConfiguration)
      webView.uiDelegate = self

        view = webView

    }

    override func viewDidLoad() {

        super.viewDidLoad()

        

        let myURL = URL(string:"https://www.apple.com")

        let myRequest = URLRequest(url: myURL!)

        webView.load(myRequest)

    }}

its not showing any error in above code

but in my app.swift file it show error. Cannot find 'ContentView' in scope

import SwiftUI

@available(iOS 14.0, *)

@main

struct Yash_RisingApp: App {

    var body: some Scene {

        WindowGroup {

            ContentView()

        }

    }

}


in this if I remove the code line  "  ContentView(). "

it successfully built on iPhone but showing blank white page not my website opening

I hope I clear my issue

Waiting for the solution.

You haven't defined anything called ContentView. All you've done is name a file ContentView.swift.

You need to have something like this:

struct ContentView : View {
    var body: some View {
        // The View you want to display
    }
}

If you want to use ViewController inside ContentView, you have to make it conform to UIViewControllerRepresentable.

See how here: https://www.hackingwithswift.com/books/ios-swiftui/wrapping-a-uiviewcontroller-in-a-swiftui-view

Cannot find 'ContentView' in scope. in Xcode 14
 
 
Q