I have added Realm and RealmSwift libraries in my iOS project. My app was fine till 2 days back. Suddenly it started giving following error.
Error:Swift package target ‘Realm’ is linked as a static library by ‘Project’ and ‘Realm’, but cannot be built dynamically because there is a package product with the same name.
I don’t find any static libraries in my app. I tried deleting library from Project->Package Dependencies. But XCode is throwing below compiler Error
Missing required modules: ‘Realm.Private’, ‘Realm’, ‘Realm.Swift’
2
Answers
This is likely due to a recent change in the Realm SDK and install setup.
Please review the Install & Setup Guide.
If you use Cocoapods, be sure your podfile matches the docs and adjust the iOS/macOS version accordingly.
If using SPM, be sure to note the info the Dynamic Framework Section
and be sure you’re only adding one package
For anyone else, as linked to by others, the Install Guide says to link to either
Realm
orRealmSwift
(not too obvious).In my case, using SPM, I had to link my target to
RealmSwift
only.