In my case, there are 2 packages: Realm and RealmSwift when adding Realm package to project. After removing the Realm and just keeping RealmSwift in Build Phases settings, my project was build successfully.
Realm
RealmSwift