Realm-cocoa: No such module: 'RealmSwift' (Xcode 10)

Created on 2 Nov 2018  路  11Comments  路  Source: realm/realm-cocoa

Goals

Install RealmSwift using CocoaPods

Expected Results

RealmSwift should run without errors

Actual Results

The CocoaPods install process in many cases does not work:
No such module 'RealmSwift'
There have been a LOT of people reporting this very issue for years.

Yet, the solution to this issue have always been standard replies (e.g. citing the flawerd install procedure), instead of investigating the issue or providing troubleshooting guidelines in the Docs.

I have been using RealmSwift for almost two years and was NEVER able to install it via CocoaPods. Manual installation with .framework files is, however, cumbersome and hard to maintain.

Please FINALLY start to investigate this issue!

Steps to Reproduce

CocoaPods Installation using Xcode 10.

Version of Realm and Tooling

Any version, actually (tried 3.1.1, 3.11.0, 3.11.1)

O-Community T-Help

Most helpful comment

After spending almost two days on this issue, I might have found the solution on my own. Xcode sometimes seems to not be able to compile RealmSwift source (error: "Could not build Objective-C module 'RealmSwift'"). Please incorporate my solution to the problem in your docs.

To overcome this issue, the module needs to be built on the project:

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

All 11 comments

After spending almost two days on this issue, I might have found the solution on my own. Xcode sometimes seems to not be able to compile RealmSwift source (error: "Could not build Objective-C module 'RealmSwift'"). Please incorporate my solution to the problem in your docs.

To overcome this issue, the module needs to be built on the project:

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

@caloon I'm getting errors like invalid redeclaration when building RealmSwift target

screen shot 2018-11-10 at 9 12 05 am

woot! okay .. somehow i fixed it by locking the version in podfile to version 3.11 ... somehow the default fetched version 3.5

same issue, invalid redeclaration.
I'm using https://github.com/realm/my-first-realm-app/tree/master/ios/SyncIntro
Xcode 9.2 compiled without problem, xcode 10.1 fail

I Go To: Product > Schemes > New Scheme... ( as explained By caloon on Nov 2, 2018)
But no RealmSwift is available for selection, only :
target station (the name of the Project ) and stationTests and stationUITests
name [ station ] (editable)

I must be thick, or just fatigued by trying to resolve multiple issues just to get this project to compile.

Podfile.lock

PODS:
  - Realm (3.12.0):
    - Realm/Headers (= 3.12.0)
  - Realm/Headers (3.12.0)
  - RealmSwift (3.12.0):
    - Realm (= 3.12.0)

DEPENDENCIES:
  - RealmSwift

SPEC REPOS:
  https://github.com/cocoapods/specs.git:
    - Realm
    - RealmSwift

SPEC CHECKSUMS:
  Realm: cdaef23c4ddb36ab1ddffed23f5a7f3332fc5585
  RealmSwift: 5576324033f0aa5ef1e0a839a3da2281dff47a7f

PODFILE CHECKSUM: a8c75fddf659659ff7c23362efd28d0cf9a64403

COCOAPODS: 1.5.3

In the Pods directory in the project directory there exists

  2098 Jan  5 15:08 ./Pods.xcodeproj/xcuserdata/dgerman.xcuserdatad/xcschemes/RealmSwift.xcscheme
   256 Jan  5 12:15 ./Target Support Files/RealmSwift
   110 Jan  5 12:15 ./Target Support Files/RealmSwift/RealmSwift.modulemap
   124 Jan  5 12:15 ./Target Support Files/RealmSwift/RealmSwift-dummy.m
   195 Jan  5 12:15 ./Target Support Files/RealmSwift/RealmSwift-prefix.pch
   576 Jan  5 12:15 ./Target Support Files/RealmSwift/RealmSwift.xcconfig
   312 Jan  5 12:15 ./Target Support Files/RealmSwift/RealmSwift-umbrella.h
   224 Jan  5 12:15 ./RealmSwift
   704 Jan  5 12:15 ./RealmSwift/RealmSwift

Just had the same issue. Been using Realm for ages on one project. Started a new prototyping project and used cocoapods to bring in RealmSwift. Odd thing is that it compiles and runs on the simulator but when I tried it on a device it failed to build with No such module...

Cleaned, restarted xcode etc.

Tried the above without success. Even when I'd rebuilt the module I ended up getting a linker error on Pod_.framework.

Going to my Linked Frameworks and Libraries section on General settings I removed the Pod_.framework and added Realm & RealmSwift there.

Suddenly I'm back in business.

Not sure I understand much of how Cocoapods framework works, but if this info helps anyone...

Screenshot 2019-03-17 at 12 40 58

thanks it works fine

I've gone through and done a bunch of different solutions. None is ever a solution that lasts. This is extremely frustrating. I'd like to use Realm because CoreData doesn't look as good. But if Swift can't find it any time I make a change to my file, then it doesn't make sense to keep using Realm. I even opened a SO issue over this and still couldn't get a lasting solution.

https://stackoverflow.com/questions/55912541/why-do-i-keep-getting-the-error-no-such-module-realmswift

So frustrating!

Not fancy, but maybe make sure you are using the workspace created by CocoaPods and not the Xcode project itself?

I just had this issue and it was being caused because I was still in the original Xcode project after installing CocoaPods. Once I realized and switched to the .xcworkspace created by CocoaPods everything compiled as expected.

I don't have time to try and make a dependency work. CoreData might not be pretty but it works. Shame, cause I do like working with Realm.

We also find the status quo quite frustrating, but we can't really do much about CocoaPods bugs. CocoaPods appears to be generating invalid dependency information in the xcode project it creates, which is not something under our control and needs to be reported to them if you're running into issues.

Was this page helpful?
0 / 5 - 0 ratings