Realm-cocoa: No Such Module 'Realm' in Swift Project

Created on 7 Jan 2015  Â·  31Comments  Â·  Source: realm/realm-cocoa

Hello,

I downloaded Realm for iOS a few minutes ago (version 0.89.2), then I follow the installation guide:

  1. Drag the Realm.framework from ios folder to my project workspace and also copy it.
  2. Adding libc++.dylib to my project
  3. Drag and copy RLMSupport.swift

After that I did import Realm in my viewcontroller, then Xcode gave me No such module 'Realm' error message. I google this issue and I found this thread in SO. It said Version 0.86 is now out and this is no longer an issue.

So, why I'm still experiencing this issue even when I use version 0.89? Please help me :)

p.s. I use Xcode 6.2 Beta

Most helpful comment

Guys, for all that have such issue here is solution: After executing pod install, close XCode and open your project not from xcodeproj file, but from xcworkspace. Then build (Cmd+B). And _POOF_ issue is gone!

All 31 comments

@bepitulaz have you tried running Clean and then re-building?

I had been doing that even restarting Xcode, but I'm still experiencing that issue.

One other thing to try is to delete your DerivedData directory. Even clean misses some stuff when using swift.

Just try to delete the DerivedData directory. It's still not working as expected.

Hi, any update for this issue?

We still haven't been able to reproduce this. When you added RLMSupport.swift did you make sure it was added to your target? Do the swift examples in the release package work for you?

We haven't heard from anyone on this in over a week, so I'm closing.

If you see this message, it can generally be fixed by following these steps:

  1. "Clean" from Xcode (Shift+Cmd+K)
  2. "Clean Build Folder" from Xcode (Option+Shift+Command+K)
  3. Quit Xcode
  4. Delete the Derived Data directory (~/Library/Developer/Xcode/DerivedData)
  5. Launch Xcode and "Build".

I am facing the same issue- I am using the installation commands for Cocoa as described in http://realm.io/docs/cocoa/0.90.1/, reproduced below-

In your Podfile, add pod "Realm" to your app target and pod "Realm.Headers" to your test target (see “Testing Realm Apps”) for details.
From the command line, run pod install.
Use the .xcworkspace file generated by CocoaPods to work on your project!
Follow these additional steps if you use Swift:
Download the latest release of Realm and extract the zip.
Drag the file at Swift/RLMSupport.swift into the File Navigator of your Xcode project, checking the Copy items if needed checkbox.

Since I am using Swift, I followed the additional step and yes, I did check Copy items if needed and added it to the application target.

However, I am getting the following error during build- No such module "Realm" in import Realm in RLMSupport.swift file.

And I tried all the following steps without success-

"Clean" from Xcode (Shift+Cmd+K)
"Clean Build Folder" from Xcode (Option+Shift+Command+K)
Quit Xcode
Delete the Derived Data directory (~/Library/Developer/Xcode/DerivedData)
Launch Xcode and "Build".

a) Using XCode6.1.1, Swift, Yosemite, iOS, Base SDK 8.1, Dep target: 7.0

There's only so much we can do @brajbong. It's quite possible things aren't working for you due to a bug in Apple's module loading process, so perhaps file a radar at http://bugreport.apple.com?

Here's a short video going through the steps of including Realm in a Swift project, in case that clarifies any of the steps: http://static.realm.io/videos/realm-in-swift.mp4

@brajbong Same here.
@jpsim Thanks for the link.

@brajbong I am having exactly the same issue here - RLMSupport.swift will not compile after Cocoapods install.

Did anyone have any success install this via cocoapods?

Same here.
@bazscott I failed too. via cocoapods.

by the way,
I try to remove import line. like below
// import Realm

It's success compile.

How about remove import?

Added ---------------------

and, I added Realm import line to "bridging-header.h", like below

import <Realm/Realm.h>

@liweiz @bazscott @lum7671 we've updated our CocoaPods installation instructions for using Realm in Swift projects. Please let us know if you still run into issues after following them here: http://realm.io/docs/cocoa#installation.

@jpsim Thanks! The problem was fixed. :-)

This issue still exists on Xcode 7.

yeah, how do I fix it?

If you have issues with this, please file a radar at https://bugreport.apple.com, as this is a common issue in Xcode.

Thanks @jpsim, I already solved, and you are right, is a Xcode issue.

I solved this by remove RealmSwift from the pod file, running pod install, building (failed), adding it to the podfile once again, and running pod install. Build succeeded.

Exactly the same, kind of weird but it worked.

Sent from my iPhone

On Dec 30, 2015, at 8:36 PM, Helson Taveras [email protected] wrote:

I solved this by remove RealmSwift from the pod file, running pod install, building (failed), adding it to the podfile once again, and running pod install. Build succeeded.

—
Reply to this email directly or view it on GitHub.

For clarity - these steps may help recreate this problem.

so I downloaded the zip from github
realm-cocoa-master.zip
extracted - navigated to the examples / ios / swift2-2 folder
I run pod install
platform :ios, '8.0'
use_frameworks!

target 'ReactKitTableView' do
pod 'ReactKit'
end

I choose tableview from the drop down menu

it fails with
screen shot 2016-03-30 at 2 48 18 am

I think you have some extra step to get it to work because I ran the
/installation/ios/swift2-2/build.sh

issuing this command - it fired up a simulator with running example no problem with one shot.
./build.sh test-osx-swift-dynamic

Subsequently - when I did a clean on project (which I had tried half a dozen times including removing build folder) - the realmswift could now be located.

If you try this on a pristine osx / xcode and cocoapods - you should be able to reproduce this.

gem -v cocoapods
2.4.6

Hi,
I have been facing similar issue with "IQKeyboardManagerSwift" any update on this, seems removing and adding back the pod doesn't help!

same issue still, nothing helps

stormcore did you try dropping into terminal and running
/installation/ios/swift2-2/build.sh ?

Guys, for all that have such issue here is solution: After executing pod install, close XCode and open your project not from xcodeproj file, but from xcworkspace. Then build (Cmd+B). And _POOF_ issue is gone!

FWIW, the output of pod install mentions to do just that:

[!] Please close any current Xcode sessions and use MyProject.xcworkspace for this project from now on.

Please close any current Xcode sessions and use MyProject.xcworkspace for this project from now on.
It's not help :(

I had this as well.

Maybe it's a weird solution, but I accidently deleted Realm.framework in Link Binary With Libraries. After that I drag Realm.framework from my project again and project start to work with all data :dancer:

UPD: If you close your project problem come back, so you can again delete and back Realm.framework :(

I was using Cocoa Pods while I got this error, resolved this by adding $'inherited' to FRAMEWORK SEARCH PATH.

@iamrohit1 I solved it in the same way.

Just building the project (cmd+b) two times helped im my case. The build failed the first time but succeeded the second time.

Was this page helpful?
0 / 5 - 0 ratings