【问题标题】:Missing required module 'Firebase' for Unit test缺少单元测试所需的模块“Firebase”
【发布时间】:2023-02-02 16:00:09
【问题描述】:
我将单元测试目标添加到现有项目中,当我在测试类中获得 @testable import Product_Module_Name 时
缺少必需的模块“Firebase”
我在项目中使用 firebase pod尝试添加HEADER_SEARCH_PATHS = "${PODS_ROOT}/Firebase/CoreOnly/Sources" 在构建设置中添加
target 'TestTargetName' do
inherit! :search_paths
end
在 pod 文件中。
但仍然出现错误缺少必需的模块“Firebase”
【问题讨论】:
标签:
ios
swift
xcode
firebase
unit-testing
【解决方案1】:
target 'GRCReportsTests' do
inherit! :search_paths
pod 'Firebase/Messaging'
end
这解决了我的问题
【解决方案2】:
我不使用 CocoaPods,而是使用 SPM。
对我来说,问题在于错误的TEST_HOST 值。
在 Xcode 14 中创建新项目后,默认值设置为:
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YourApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/YourApp";
它导致最终路径有一个额外的斜线 - build/Debug-iphoneos/YourApp.app//YourApp
对我有用的是从 TEST_HOST 中删除 /$(BUNDLE_EXECUTABLE_FOLDER_PATH)