15
votes

I configured RealmSwift 1.0.0 Latest Using Docs into the Xcode project. After installation i created a class file and getting module error - like: No such module 'RealmSwift' in class file.

1.

enter image description here

2.

enter image description here

3. enter image description here

4. enter image description here

  1. After adding the Realm Plugin, i created a class and get the module error below.

enter image description here

Please help me to solve this error.

13

13 Answers

8
votes

It looks like you've added the path to RealmSwift.framework to your framework search paths. The Realm Swift installation instructions say to add the parent path of RealmSwift.framework (i.e., the containing directory) to your framework search paths.

21
votes

A very important sanity check: if you run into this and you're using Cocoapods, please make sure you open the .xcworkspace and not the .xcodeproj file!

14
votes

Follow below steps, it may be useful for you.

  • Go To: Product > Schemes > New Scheme...
  • Select: RealmSwift and click OK
  • Build the RealmSwift target (cmd + b)
4
votes

I had the same problem like you. I resolved it by add the following code into pod file.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
2
votes

Follow below instructions:

  1. Clean from Xcode (Shift+Cmd+K)
  2. Delete the Derived Data directory (~/Library/Developer/Xcode/DerivedData)
  3. Build the project (Cmd+B)
0
votes

I've struggled with this problem as well for 2 hours; I tried several things, like cleaning, uninstalling and reinstalling the Realm pod, changing the Podfile, and so on.

Nothing worked until I restarted the computer.

I use Xcode 8.3.3 and Xcode 9.2 Beta, Swift 3, High Sierra MacOS.

0
votes

After "pod install" restart Xcode

0
votes

You can add Run script file for your project.

"${SRCROOT}/Pods/Target Support Files/Pods-Realm Database/Pods-Realm Database-frameworks.sh"
0
votes

let me tell you How I get that error and I solve it.

I am using Carthage in my project. but I am new team member, so I did git-clone the project. But I opened the project before run cathage upload command. Although I ran the cathage command, I got that error. I could fix it doing the next:

Go to the project file. In build phaces -> run script -> Input file. Add $(SRCROOT)/Carthage/Build/iOS/Realm.framework And $(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework

I do not know why it is not always automatically linked .

Best Regards!

0
votes

For me there first was an error like 'could not build Objective-C module 'RealmSwift'' which I could fix by deleting the Derived Data Folder, Pods Folder, Podfile.lock and the .xcworkspace and after that there was the error saying 'No such module 'RealmSwift'' which only disappeared when I first tried to build the project. Now everything works fine for me!

0
votes

After "pod install" or "pod update" fix it

else

try this:

sudo gem install cocoapods-deintegrate cocoapods-clean    
pod deintegrate    
pod cache clean --all      
rm Podfile    
pod "deinitialize" to fix that issues.
0
votes

In my case i tried other suggested solutions and it didn't work for me but this replacement fixed problem and the error have gone

Try use

pod 'RealmSwift'

instead

pod 'Realm', '~> 10.1'
-2
votes

In my case, setting project format to current Xcode version in pod target helped:

https://i.stack.imgur.com/VqozI.png