gpt4 book ai didi

ios - 使用 Cocoapods 进行 Xcode 单元测试

转载 作者:IT王子 更新时间:2023-10-29 07:29:10 24 4
gpt4 key购买 nike

在过去的几天里,我一直在用这个问题撞墙,但尽管在 Google/SO/Github 上进行了多次搜索,我还是找不到解决我遇到的问题的方法!

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

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

使用这个播客文件:

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 类中,我得到了

Missing required module 'Firebase'

@testable import MyApp 处出错

或者使用这个 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

测试成功,但我的控制台上到处都是警告,例如:

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

最佳答案

我遇到了同样的问题。我通过将 pod 'Firebase' 移动到我的测试目标来解决它。将您的 Podfile 更改为:

platform :ios, '9.0'
use_frameworks!
inhibit_all_warnings!

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

target 'MyAppTests' do
inherit! :search_paths
pod 'Firebase'
end
end

关于ios - 使用 Cocoapods 进行 Xcode 单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38216090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com