使用Cocoapods进行Xcode单元测试 [英] Xcode Unit Testing with Cocoapods

查看:429
本文介绍了使用Cocoapods进行Xcode单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几天里,我一直用头撞墙,但尽管有多次Google / SO / Github搜索,我找不到解决我遇到的问题的方法!

I've been banging my head against a wall with this for the last few days but despite multiple Google/SO/Github searches I can't find a resolution to the issues I'm having!

我要做的就是为我的应用程序创建一些使用Firebase pod的单元测试。

All I'm trying to do is create some unit tests for my app which makes use of Firebase pods.

我正在使用Xcode 7.3.1& Cocoapods 1.0.1。 更新:问题仍然存在于Xcode 8.0

I'm using Xcode 7.3.1 & Cocoapods 1.0.1. Update: Issue remains with Xcode 8.0

使用此podfile:

With this podfile:

platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!

target 'MyApp' do
    pod 'Firebase'
    pod 'Firebase/Auth'
    pod 'Firebase/Database'
    pod 'Firebase/Storage'

    target 'MyAppTests' do
        inherit! :search_paths
    end
end

在我的XCTest课程中我得到了

In my XCTest class I get


缺少所需模块'Firebase'

Missing required module 'Firebase'

错误 @testable import MyApp

或者使用此podfile:

Alternatively with this podfile:

platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!

def common_pods
    pod 'SwiftyTimer'
    pod 'Firebase'
    pod 'Firebase/Auth'
    pod 'Firebase/Database'
    pod 'Firebase/Storage'
end

target 'MyApp' do
    common_pods
end

target 'MyAppTests' do
    common_pods
end

测试构建但我的控制台上堆满了警告,例如:

The tests build but my console is littered with warnings e.g.:


Class< -FirebaseClassName->在...中实现... MyApp ...和
... MyAppTests ...将使用两者之一。哪一个未定义

Class <-FirebaseClassName-> is implemented in both ...MyApp... and ...MyAppTests... One of the two will be used. Which one is undefined


推荐答案

我的解决方案是将cocoapods更新到版本1.1.0 .rc.2。

The solution for me was to update cocoapods to version 1.1.0.rc.2.

sudo gem install cocoapods --pre

这篇关于使用Cocoapods进行Xcode单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆