Realm-cocoa: No such module: 'RealmSwift' (CocoaPods 1.2.0, Xcode 8.3.2, Realm 2.7.0)

Created on 24 May 2017  路  14Comments  路  Source: realm/realm-cocoa

Goals

Install Realm through CocoaPods

Expected Results

Much like other successfully installed Pods (AlamoFire, SwiftyJSON, HDAugmentedReality) it to install without issue

Actual Results

Build Failed - No such module: 'RealmSwift'

Steps to Reproduce

I have tried this on both existing projects as well as on a new project.

Code Sample

````
import UIKit
import RealmSwift

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}
````

Version of Realm and Tooling

ProductName:    Mac OS X
ProductVersion: 10.12.4
BuildVersion:   16E195

/Applications/Xcode.app/Contents/Developer
Xcode 8.3.2
Build version 8E2002

/usr/local/bin/pod
1.2.0
Realm (2.7.0)
Realm (~> 2.7)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)


(not in use here)

/usr/bin/git
git version 2.11.0 (Apple Git-81)
T-Help

All 14 comments

Did you problem also go away after you did a build?

It didn't. I had to do a fully manual install in order to get Realm installed.

Yep getting this as well when installing via cocoapods. No such module: 'RealmSwift'. Quite frustrating.

@aamck I had to install it using the following instructions. Hope that this helps you.
https://stackoverflow.com/questions/31896667/how-to-add-the-parent-path-to-realmswift-framework-in-the-framework-search-path

@garethallenstringer Yeah I installed it manually but it's a pain in the arse. My project is early days and I'm trying out various alternatives to CoreData so between this and the warnings spam from another issue I might pass on it for now & try something else. Thanks for the response though.

@aamck It was a big ol' pain in the arse indeed. Now that it is working though, I have found it to be absolutely brilliant. Especially with the Realm Browser (though finding the .realm file was an absolute nightmare, and required me to install https://github.com/luosheng/OpenSim) which worked like a charm.

I'm sorry about the difficulty you had installing Realm via CocoaPods. Would you be willing to share your podfile, or at least the declaration you used to add Realm Swift to your podfile?

platform :ios, '10.0'

target 'App' do
  use_frameworks!
  pod 'RealmSwift'

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end

A few notes in the future to check if you do run into build issues again:

  1. Make sure you're using supported tools & versions, and to follow the installation instructions. As of this writing:

    1. Install CocoaPods 0.39.0 or later.
    2. Run pod repo update to make CocoaPods aware of the latest available Realm versions.
    3. In your Podfile, add use_frameworks! and pod 'RealmSwift' to your main and test targets.
    4. Paste the following at the bottom of your Podfile, updating the Swift version if necessary:

      post_install do |installer|
       installer.pods_project.targets.each do |target|
         target.build_configurations.each do |config|
           config.build_settings['SWIFT_VERSION'] = '3.0'
         end
       end
      end
      
    5. From the command line, run pod install.

    6. Use the .xcworkspace file generated by CocoaPods to work on your project!

If you're still running into issues building/installing with CocoaPods, please share the full unabridged output of these commands:

pod --version
pod cache clean Realm
pod cache clean RealmSwift
pod deintegrate || rm -rf Pods
pod install --verbose
rm -rf ~/Library/Developer/Xcode/DerivedData

After running those commands, please attempt to build your project.


From my reading of this thread, it appears that everyone sorted this out eventually, so I'll now be closing this. Please feel free to re-open if following the instructions I shared above doesn't resolve the issues you're seeing, or file a new issue. Thanks!

@garethallenstringer I realised that I was trying to import RealmSwift into a class that was targeted to iOS and a watchOS extension. When I removed the watch extension target then did a clean & build the error went away.

Running the pod install script works, but it's setting the Swift Version to 3.0. Is RealmSwift not available for Swift 4? When I update to Swift 4 with Xcode 9, I get the same error. Not sure, if this should be a new issue, since it only pertains to updated versions of Swift & Xcode 9.

@michaelcordero I'd suggest that maybe this ought to be a separate issue, as it pertains to Swift 4 and my issue does not.

Hello @michaelcordero ,
Open this link: https://realm.io/docs/swift/latest/ and download. Add the swift 4 folder framework files to your xcode 9 and add them in your project in build link. It works.

Please don't comment on closed issues like this. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TheHmmka picture TheHmmka  路  3Comments

javierjulio picture javierjulio  路  3Comments

carvalho-oak picture carvalho-oak  路  3Comments

xspyhack picture xspyhack  路  3Comments

dennisgec picture dennisgec  路  3Comments