Cococapods的框架导致警告“类XY实现在两者中”

时间:2015-03-26 07:48:31

标签: ios cocoapods

我有一个带有可可触控框架的iOS项目,我想使用CocoaPods。据我所知,一切都运行正常,但我收到了包含所有pod的以下警告(此处以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.

我将Xcode项目上传到github,它可以在这里找到:https://github.com/haemi/FrameworkWithCocoaPods

这里有两张来自当前设置的图片:

enter image description here

enter image description here

4 个答案:

答案 0 :(得分:1)

您必须使用Xcode项目打开您的项目,但您应该使用由Cocoa pods创建的Xcode Workspace打开您的项目。

该项目不包括Pods文件,因为它不包含这些框架并以红色显示。

通过工作区打开项目可以解决您的问题。

已更新:

  1. 只需更改设置即可删除以前出现的错误:
  2. enter image description here

    1. 将设置更改为:
    2. enter image description here

      1. 它会解决之前的错误但会产生PODS的新错误以删除错误,只需删除Check Pods manifest.lock并复制pods资源。
      2. enter image description here

        1. 只需删除MyHelper.h和MyHelper.m文件。

        2. 添加新的MyHelper类,但这次将目标更改为FrameworkPlayground并放置之前的相同内容并将#import导入MyHelper.h文件。

        3. enter image description here

答案 1 :(得分:1)

有同样的问题。通过删除项目的派生数据解决了这个问题。转到窗口 - >单击项目,选择项目,然后单击派生数据部分右侧的“删除”按钮。返回到Xcode窗口并使用命令+ option + shift + k清理构建文件夹。然后去你的模拟器,iOS模拟器 - >重置内容和设置。返回Xcode窗口,构建项目并运行。这仅适用于已发布派生数据的人。

答案 2 :(得分:1)

从以下位置更改您的pods文件:

target 'App' do
   # all your pods
end

target 'AppTests' do
   # all your pods
end

为:

target 'App' do
    # all your pods

    target 'AppTests' do
        inherit! :search_paths
    end
end

答案 3 :(得分:0)

首先跟随this answer清除我的派生数据,但重新编译时出现编译错误。最终从this answer获得了修复。基本上,罪魁祸首似乎是在项目设置中的其他链接器标志下,Pod被链接两次。