Jobs
Jobs

Reputation: 658

RealmSwift installation on Xcode

I am trying to create a project which uses Realm and RealmSwift. I have used Cocoapods to install these dependencies. I have seen the other posts too on stackoverflow and tried their solutions. They don't work for me. In my project, I'm getting the error "No such module as RealmSwift" when I write the import RealmSwift statement. Here are the steps I took for installation:

  1. I created an empty xcode project
  2. I went into terminal and navigated to my project directory
  3. I gave the pod init command to create a pod file
  4. I went into the pod file(it already had the use_frameworks! statement
  5. I wrote in pod 'Realm' and pod 'RealmSwift'. I gave the sources as:

    source 'https://github.com/artsy/Specs.git'

    source 'https://github.com/CocoaPods/Specs.git'

enter image description here

  1. I wrote in pod install
  2. The pods were installed successfully. I went into the .xcworkspace file.
  3. I had already installed the realm plugin so I created a new realm object file
  4. The template file opens with the following file. I'm getting the error that there is no RealmSwift module.

enter image description here

What am I doing wrong? Or what am I not doing? Is a bridging header required? Has anybody else managed to resolve this error?

Any relevant suggestions or insights are most welcome.

Upvotes: 2

Views: 4296

Answers (2)

Anand Nimje
Anand Nimje

Reputation: 6251

Need to uncomment platform in your pod file then try once again your pod.

# Uncomment this line to define a global platform for your project
  platform :ios, '9.0'   // Uncomment this 

# Uncomment this line if you're using Swift
 use_frameworks!

target 'Demo_Realm' do
pod 'RealmSwift'
end

target 'Demo_RealmTests' do

end

target 'Demo_RealmUITests' do

end

Upvotes: 0

Jobs
Jobs

Reputation: 658

Its working now! Its so weird since I didn't do anything. I just went into my pod file commented out the use_frameworks! statement and ran pod update on the terminal. It gave me an error, so I added it back to my pod file. I wrote in pod update again and hit enter. I restarted Xcode cleaned it and built it and I wasn't getting this error anymore.

Upvotes: 2

Related Questions