So I wanted to link to RealmSwift in my own framework and these are the steps I took:
Add
RealmSwift
as a subprojectLink the framework:
Add the dependency
Import
RealmSwift
into the Swift file:
And I got the error: Missing required modules: 'Realm.Private', 'Realm'
. How can I solve this issue? Thanks!
As of Realm v0.93.0, RealmSwift.framework no longer embeds Realm.framework. This causes the same missing module error message when you upgrade. You can resolve it by linking directly to both RealmSwift.framework and Realm.framework. You'll also need to remove any pre-existing strip-frameworks.sh Run Script Phase in your app's target's Build Phases. This step is no longer needed.
You'll need to add
/path/to/RealmSwift.framework/Frameworks
to the “Framework Search Paths” section in Build Settingswhere
/path/to/RealmSwift.framework
is the location of the framework.This is because
RealmSwift.framework
depends onRealm.framework
(where theRealm
andRealm.Private
modules are defined), which is vendored in itsFrameworks
directory.Something similar happened to me when I did the pod install...
Make sure you open the appname.xcworkspace file not the appname.xcodeproj after doing the pod-install with CocoaPods.
The error No such module 'RealmSwift' will occur from any file where 'import RealmSwift' is set up if not opened from appname.xcworkspace.