How to resolve the conflict between RealmSwift.App and SwiftUI.App in SwiftUI after iOS 14.0?

I can not use App directly,nor can use RealmSwift.App,what can i do to resolve the conflict?

import SwiftUI
import RealmSwift

let app = RealmSwift.App(id: "tasktracker-qczfq")
@main
struct LandManagementApp: SwiftUI.App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
Error:Module 'RealmSwift' has no member named 'App'
import SwiftUI
import RealmSwift

let app = App(id: "tasktracker-qczfq")
@main
struct LandManagementApp: SwiftUI.App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
Error:Argument passed to call that takes no arguments
Error:Protocol type 'App' cannot be instantiated

I installed Realm with swift manager package and did not change any build settings.

Try not putting the “import RealmSwift” statement in this file. You don’t need it there anyways. I have the same problem if I put it in the app file. You can put it in the other files just fine.

@Stephen_Zhuang Realm Sync is not available via SPM, please use Cocoapods if you use to use full MongoDB Realm functionality.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.