Cocoapods测试问题 - 重复“将使用其中一个。哪一个是未定义的。“

问题描述 投票:3回答:3

我一直试图解决这个问题几天,但没有找到解决方案。每当我尝试运行测试时,我都会收到下面显示的错误,即有重复的类。

我尝试了这些答案,但我仍然收到重复的错误,我的测试将无法运行

Cocoapods Warning - CocoaPods did not set the base configuration of your project because because your project already has a custom config set

我的pod文件如下所示:

platform :ios, "8.0"

def project_pods
pod "Braintree"
pod "AFNetworking", "~> 3.0"
pod "MBProgressHUD"
pod "ActionSheetPicker-3.0", "~> 2.0.1"
pod "SCLAlertView-Objective-C", "~> 0.7"
pod "GoogleMaps"
pod "MPSHorizontalMenu"
pod "Fabric"
pod "Crashlytics"
pod "RateView"
pod "QBImagePickerController"
pod "GLCalendarView", "~> 1.0.0"
pod "Heap"
pod "AWSS3"
end

target “iOS_project” do
    project_pods
end

target “iOS_projectTests” do
project_pods
end

这就是错误的样子,它适用于每个cocoapod类:

类GMSAutocompleteResultsViewController在/Users/john/Library/Developer/CoreSimulator/Devices/27CF0470-07AC-4575-8907-A27EE9B357A7/data/Containers/Bundle/Application/7AFB0886-9ED1-464D-8B02-067CDD07511D/iOS_project.app中实现。 / iOS_project和/Users/john/Library/Developer/Xcode/DerivedData/iOS_projectTests-hezbkjqviaiitthcrrnwetvcojcb/Build/Products/Debug-iphonesimulator/iOS_projectTests.xctest/iOS_projectTests。将使用两者之一。哪一个未定义。

所有的pod都是Objective C,我正在使用一个桥接头

ios xcode swift
3个回答
1
投票

重新格式化您的podfile,如下所示:

platform :ios, "8.0"

def project_pods
    pod "Braintree"
    pod "AFNetworking", "~> 3.0"
    pod "MBProgressHUD"
    pod "ActionSheetPicker-3.0", "~> 2.0.1"
    pod "SCLAlertView-Objective-C", "~> 0.7"
    pod "GoogleMaps"
    pod "MPSHorizontalMenu"
    pod "Fabric"
    pod "Crashlytics"
    pod "RateView"
    pod "QBImagePickerController"
    pod "GLCalendarView", "~> 1.0.0"
    pod "Heap"
    pod "AWSS3"

    target "iOS_projectTests" do
        inherit! :search_paths
    end
end

target "iOS_project" do
    project_pods
end

资料来源:CocoaPods issue #4626


0
投票

该错误表示'GMSAutocompleteResultsViewController'已集成两次,并且只使用了一个

如果您现在不使用单元测试用例目标,则可以从podfile中删除该部分,然后再次通过pod installpod update进行检查

从podfile中删除此部分

target “iOS_projectTests” do
project_pods
end

对于swift来说,如果你将use_frameworks!设置在平台版本之下会更好

所以你的上半部分就像

platform :ios, "8.0"
use_frameworks!

所以你的新podfile看起来像这样

platform :ios, "8.0"
use_frameworks!

def project_pods
pod "Braintree"
pod "AFNetworking", "~> 3.0"
pod "MBProgressHUD"
pod "ActionSheetPicker-3.0", "~> 2.0.1"
pod "SCLAlertView-Objective-C", "~> 0.7"
pod "GoogleMaps"
pod "MPSHorizontalMenu"
pod "Fabric"
pod "Crashlytics"
pod "RateView"
pod "QBImagePickerController"
pod "GLCalendarView", "~> 1.0.0"
pod "Heap"
pod "AWSS3"
end

target “iOS_project” do
    project_pods
end

target “iOS_projectTests” do
project_pods
end

希望这会有所帮助,如果它仍然显示错误,您可以将pod直接放在目标上,而不是将def放在顶部

注意:对于谷歌地图,你也可以直接导入import GoogleMaps这样的框架,而不是在桥接头中添加谷歌地图


0
投票

现在,通过评论use_frameworks!来修改Podfile,如下所示:

platform :ios, '8.0'

#use_frameworks!

target 'ShiBa' do

    pod 'SDWebImage'
    pod 'AFNetworking'
    pod 'MBProgressHUD'
    pod 'MJRefresh', '3.1.0'
    pod 'UMengAnalytics'
    pod 'YYModel'
    pod 'AMapLocation'
    pod 'pop'

end
© www.soinside.com 2019 - 2024. All rights reserved.