1
votes

I trying to use RealmSwift using cocoapods but I getting No Such Module "RealmSwift" error.

The pod install was successful and installed Realm 2.2.0

I already tried clean build and build folder and derived data I also created a dummy project and did a clean install, it still doesn't work. When I just try importing RealSwift and build, the build succeeds but after that, the error comes back.

This is my Podfile

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

target 'RealmDummyProject' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for RealmDummyProject
 pod 'RealmSwift'

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

end

I am using Xcode version 8.1 (8B62) with Swift 3.0 Thanks!

2
"When I just try importing RealSwift and build, the build succeeds but after that, the error comes back." – does this mean that you're able to compile and run the app?Dmitry
yes, when first launching the workspaceirkinosor
In this case it seems like Xcode has probably just cached some previous errors, please try to clean the project and build folder, restart Xcode etc and rebuild the app.Dmitry

2 Answers

1
votes

Use the .xcworkspace file generated by CocoaPods instead of .xcodeproj to work on your project. And, I believe your PodFile should look like this:

From Realm Installation:

If using Xcode 8, paste the following at the bottom of your Podfile...

target 'RealmDummyProject' do
  use_frameworks!

  # Pods for RealmDummyProject
  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

Also, this might help you: RealmSwift installation on Xcode

0
votes

Just had a similar issue.

You should "Compile the project" right after you open the .xcworkspace file.

Since it looks like if you are using a specific Pod for the first time XCode doesn't know about it until you compile the whole workspace.