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

时间:2016-01-13 17:27:28

标签: ios xcode swift

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

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

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,我正在使用桥接头

3 个答案:

答案 0 :(得分: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

答案 1 :(得分: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

答案 2 :(得分: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放在顶部

注意:对于Google地图,您还可以直接导入import GoogleMaps等框架,而不是在桥接标题中添加Google地图