4

So I wanted to link to RealmSwift in my own framework and these are the steps I took:

  1. Add RealmSwift as a subproject

    enter image description here

  2. Link the framework:

    enter image description here

  3. Add the dependency

    enter image description here

  4. Import RealmSwift into the Swift file:

    enter image description here

And I got the error: Missing required modules: 'Realm.Private', 'Realm'. How can I solve this issue? Thanks!

  • I can copy the Realm.framework out of the RealmSwift.framework and the message disappears. But then RLMObject is not found. How about you? – brainray May 11 '15 at 15:29

3 Answers3

5

You'll need to add /path/to/RealmSwift.framework/Frameworks to the “Framework Search Paths” section in Build Settings

where /path/to/RealmSwift.framework is the location of the framework.

This is because RealmSwift.framework depends on Realm.framework (where the Realm and Realm.Private modules are defined), which is vendored in its Frameworks directory.

raw3d
  • 3,415
  • 1
  • 21
  • 25
jpsim
  • 14,139
  • 5
  • 49
  • 67
  • Cocoapods should take care of all this. Is this a bug in the latest version? – dwaz Aug 21 '15 at 23:36
  • The original question was in reference to using Xcode subprojects, so CocoaPods is irrelevant. You're correct in assuming that CocoaPods takes care of all this setup, however. – jpsim Aug 22 '15 at 16:51
  • How do I find this path exactly? I'm using SPM. – syntakks Feb 17 '22 at 00:25
2

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.

Oran Dennison
  • 3,205
  • 28
  • 37
0

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.