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:
- I created an empty xcode project
- I went into terminal and navigated to my project directory
- I gave the
pod init
command to create a pod file - I went into the pod file(it already had the
use_frameworks!
statement I wrote in
pod 'Realm'
andpod 'RealmSwift'
. I gave the sources as:source 'https://github.com/artsy/Specs.git'
- I wrote in
pod install
- The pods were installed successfully. I went into the .xcworkspace file.
- I had already installed the realm plugin so I created a new realm object file
- The template file opens with the following file. I'm getting the error that there is no RealmSwift module.
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.
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.
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
来源:https://stackoverflow.com/questions/38352111/realmswift-installation-on-xcode