Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Framework with Cococapods leads to warning "Class XY is implemented in both"

Tags:

ios

cocoapods

I have a iOS project with a cocoa touch framework where I'd like to use CocoaPods. Everything runs and behaves correctly, as far as I can tell, but I'm getting the following warning for all the pods included (here with the example of MagicalRecord.

objc[56961]: Class MagicalRecord is implemented in both /Users/stefan/Library/Developer/Xcode/DerivedData/FrameworkPlayground-ecdubsjzkmacfihjxoxvlznqvgmg/Build/Products/Debug-iphonesimulator/SharedDataSource.framework/SharedDataSource and /Users/stefan/Library/Developer/CoreSimulator/Devices/41B1BE94-1242-4538-8D60-23BAC3337308/data/Containers/Bundle/Application/B8ADA4E6-02BC-4095-8A14-D254C13D0928/FrameworkPlayground.app/FrameworkPlayground. One of the two will be used. Which one is undefined.
objc[56961]: Class PodsDummy_Pods_MagicalRecord is implemented in both /Users/stefan/Library/Developer/Xcode/DerivedData/FrameworkPlayground-ecdubsjzkmacfihjxoxvlznqvgmg/Build/Products/Debug-iphonesimulator/SharedDataSource.framework/SharedDataSource and /Users/stefan/Library/Developer/CoreSimulator/Devices/41B1BE94-1242-4538-8D60-23BAC3337308/data/Containers/Bundle/Application/B8ADA4E6-02BC-4095-8A14-D254C13D0928/FrameworkPlayground.app/FrameworkPlayground. One of the two will be used. Which one is undefined.

I uploaded the Xcode project to github, it's available here: https://github.com/haemi/FrameworkWithCocoaPods

Here two pictures from the current setup:

enter image description here

enter image description here

like image 477
swalkner Avatar asked Mar 26 '15 07:03

swalkner


People also ask

Is CocoaPods a framework?

A shared framework in Cocoapods is refered to as a pod . Once we have captured our project targets and its requirements we have to tell Cocoapods to set up our project based on our project specification.

What is use frameworks in Podfile?

use_frameworks! in the Podfile means that we want the listed frameworks to be dynamically installed instead as static frameworks.


2 Answers

Change your pods file from:

target 'App' do
   # all your pods
end

target 'AppTests' do
   # all your pods
end

to:

target 'App' do
    # all your pods

    target 'AppTests' do
        inherit! :search_paths
    end
end
like image 58
zalogatomek Avatar answered Oct 22 '22 08:10

zalogatomek


You must be opening your project with Xcode project but you should open your project with Xcode Workspace which is created by cocoa pods.

The project is not including the Pods file because of which those frameworks are not included and are shown in red Color.

Opening your project through workspace would resolve your issue.

Updated :

  1. Just change the Setting to remove the error that used to come :

enter image description here

  1. Change the Setting to :

enter image description here

  1. It would resolve the previous error but it would generate new errors of PODS to remove the error just remove Check Pods manifest.lock and copy pods resources.

enter image description here

  1. Just Delete MyHelper.h and MyHelper.m file.

  2. Add new MyHelper class but this time change the target to FrameworkPlayground and put the same content which was there before and import #import into MyHelper.h file.

enter image description here

like image 1
Dheeraj Singh Avatar answered Oct 22 '22 07:10

Dheeraj Singh