'"App' is ambiguous for type lookup in this context." Getting this error while importing Realm in swiftui project
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.
Solution 1:[1]
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()
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RTXGamer |
