Home > other >  "App' is ambiguous for type lookup in this context." Getting this error while importi
"App' is ambiguous for type lookup in this context." Getting this error while importi

Time:03-17

 import SwiftUI
 import RealmSwift

 @main
 struct RealmUpdatedDemoApp: App {
     var body: some Scene {
         WindowGroup {
             ContentView()            
         }
     }
 }

On importing RealmSwift on the main App file, I am getting this error but not on other files.

CodePudding user response:

Its a case of name collision, explicitly specify the namespace SwiftUI for App, if you want to import RealmSwift in this class:

Example:

import SwiftUI
import RealmSwift

@main
struct SwiftUITestApp: SwiftUI.App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
  • Related