3

I've been trying to solve this issue for a couple days and haven't found a solution. Whenever I try to run a test I receive the error shown below that there are duplicate classes.

I tried these answers but I'm still receiving the duplicate error and my tests won't run

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

My pod file looks like this:

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

This is what the error looks like and it is for every cocoapod class:

Class GMSAutocompleteResultsViewController is implemented in both /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 and /Users/john/Library/Developer/Xcode/DerivedData/iOS_projectTests-hezbkjqviaiitthcrrnwetvcojcb/Build/Products/Debug-iphonesimulator/iOS_projectTests.xctest/iOS_projectTests. One of the two will be used. Which one is undefined.

All of the pods are Objective C and I am using a bridging header

Community
  • 1
  • 1
brl214
  • 527
  • 1
  • 6
  • 16

3 Answers3

1

Reformat your podfile like this:

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

Source: CocoaPods issue #4626

Rok Jarc
  • 18,765
  • 9
  • 69
  • 124
0

The error indicates that ' GMSAutocompleteResultsViewController' is integrated two time and only one is used from it

If you are not using unit testing case target for now you can remove that portion from the podfile and check again by pod install or pod update

Remove this portion from your podfile

target “iOS_projectTests” do
project_pods
end

For swift it will be good if you set use_frameworks! below the platform version

so your top portion can be like

platform :ios, "8.0"
use_frameworks!

so your new podfile can look like this

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

Hope this helps, if it still shows the error you may put pods directly on the target instead of putting in def at top

Note: For the Google map you can also directly import the framework like import GoogleMaps instead of adding google maps in the bridging header

HardikDG
  • 5,892
  • 2
  • 26
  • 55
  • That's the issue I am having is I want to use unit testing. – brl214 Mar 28 '16 at 15:13
  • @brl214 when this error comes, i have added full podfile from your question in my project and it runs successfully for both main target and test, so after which change it comes in error ? – HardikDG Mar 29 '16 at 02:41
  • Did you add the `GMSAutocompleteResultsViewController ` or any other google map file in the bridging header – HardikDG Mar 29 '16 at 02:46
  • @brl214 yes, you are getting the same issue when you try the code in an answer? – HardikDG Apr 12 '16 at 02:51
-1

now, modify Podfile by commenting use_frameworks! ,like below:

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
Andriy
  • 2,767
  • 2
  • 21
  • 29
CoderSun
  • 1
  • 1