No such a module 'Firebase' in Tests.swift file after Converting to swift 3

北城以北 提交于 2019-12-12 18:08:14

问题


After I converted the project to swift 3 I'm getting this error in Test.swift file:

No such module 'Firebase'
Command/usr/bin/ditto failed with code 1 

is that mean I have to update the firebase framework? Why that happened?

*The application still runs though!

*Here's the pod file:

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

use_frameworks!

target 'TheTestingApp' do
pod 'Firebase' 
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
end

回答1:


The issue is you are using the mentioned Cocoapods for TheTestingApp only you also need to add these or the Cocoapods you wanna use for the TheTestingAppTest

Also Clean your project : - CMD+SHIFT+K, Then run pod install & then run your app.

Something like this:-

use_frameworks!

target 'TheTestingApp' do

    pod 'Firebase' 
    pod 'Firebase/Auth'
    pod 'Firebase/Database'
    pod 'Firebase/Storage'

end

target 'TheTestingAppTests' do

    pod 'Firebase' 
    pod 'Firebase/Auth'
    pod 'Firebase/Database'
    pod 'Firebase/Storage'

end



回答2:


I've been using Firebase in my personal project and I was able to do my Unit Test but tonight I encountered this annoying error in my new project. While Dravidian's answer is correct, it is a bit incomplete and code is redundant. I wrote a blog about this: http://www.prettyitgirl.com/2017/07/how-to-fix-missing-required-module-in.html and to summarize, here are the steps on how I solved this problem :)

  1. Make sure that all your dependencies are targeting Swift 3.0 version and add your test target under your main target, like so:

    target 'ProjectName' do
    
      pod 'Firebase/Auth'
      pod 'Firebase/Core'
      pod 'Firebase/Database'
      pod 'Firebase/Messaging'
      pod 'Firebase/Storage'
    
    target 'ProjectNameTests' do
      inherit! :search_paths
    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
    end
    
  2. Add a search path in your Header Search Paths In your Tests target’s Build Settings, search for Header Search Paths and add these two new search paths:

    $(SRCROOT)/Pods (recursive)
    ${PODS_ROOT}/Firebase/Core/Sources (non-recursive)
    

EZ! :)




回答3:


you check your podfile its already in declare at that time your project has been clean (ctrl+shift+k) Otherwise podfile data erase and again podfile install its should better work..



来源:https://stackoverflow.com/questions/39563628/no-such-a-module-firebase-in-tests-swift-file-after-converting-to-swift-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!