CocoaPods 文件引用是多个组的成员

CocoaPods file reference is a member of multiple groups

我有一个带有共享扩展的应用程序。我的应用程序依赖于 CocoaLumberjack/Default,我的共享扩展依赖于 CocoaLumberjack/Core。当我使用 use_frameworks! 构建时,出现以下错误:

$ rm -rf Pods Podfile.lock; pod install
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Installing CocoaLumberjack (2.0.3)
Generating Pods project

2015-10-28 10:46:04.015 ruby[53095:3440989] warning: The file reference for "CocoaLumberjack.framework" is a member of multiple groups ("Products" and "Products"); this indicates a malformed project. Only the membership in one of the groups will be preserved (but membership in targets will be unaffected). If you want a reference to the same file in more than one group, please add another reference to the same path.

Integrating client project
Sending stats
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 1 total
pod installed.

[!] [Xcodeproj] Generated duplicate UUIDs:

PBXFileReference -- /mainGroup/children/children:displayName:CocoaLumberjack.framework,explicitFileType:wrapper.framework,includeInIndex:0,isa:PBXFileReference,name:CocoaLumberjack.framework,path:CocoaLumberjack.framework,sourceTree:BUILT_PRODUCTS_DIR,,displayName:CocoaLumberjack.framework,explicitFileType:wrapper.framework,includeInIndex:0,isa:PBXFileReference,name:CocoaLumberjack.framework,path:CocoaLumberjack.framework,sourceTree:BUILT_PRODUCTS_DIR,,displayName:Pods_MyProject.framework,explicitFileType:wrapper.framework,includeInIndex:0,isa:PBXFileReference,name:Pods_MyProject.framework,path:Pods_MyProject.framework,sourceTree:BUILT_PRODUCTS_DIR,,displayName:Pods_MyShare.framework,explicitFileType:wrapper.framework,includeInIndex:0,isa:PBXFileReference,name:Pods_MyShare.framework,path:Pods_MyShare.framework,sourceTree:BUILT_PRODUCTS_DIR,,displayName:Products,isa:PBXGroup,name:Products,sourceTree:,/Products/children/displayName:CocoaLumberjack.framework,explicitFileType:wrapper.framework,includeInIndex:0,isa:PBXFileReference,name:CocoaLumberjack.framework,path:CocoaLumberjack.framework,sourceTree:BUILT_PRODUCTS_DIR,/Products/CocoaLumberjack.framework

这是我的 Podfile:

workspace 'MyWorkspace'
xcodeproj 'MyProject/MyProject.xcodeproj'

use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'

link_with 'MyProject', 'MyShare'

target :MyProject do
  pod 'CocoaLumberjack', '~> 2.0.1'
end

target :MyShare do
  pod 'CocoaLumberjack/Core', '~> 2.0.1'
end

我可以通过让我的两个目标使用相同的 CocoaLumberjack 子规范来解决这个问题。我的工作Podfile如下:

workspace 'MyWorkspace'
xcodeproj 'MyProject/MyProject.xcodeproj'

use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'

link_with 'MyProject', 'MyShare'

target :MyProject do
  pod 'CocoaLumberjack/Core', '~> 2.0.1'
end

target :MyShare do
  pod 'CocoaLumberjack/Core', '~> 2.0.1'
end

为什么需要此解决方法?当我实际上在两个目标之间具有不同的子规范依赖性时会发生什么?

编辑

这看起来与 CocoaPods Issue 4370. I posted my example project on github 相关。

这是 Cocoapods 中的一个错误 - 可能在很长一段时间内不会被修复 -

终端上的

运行 export COCOAPODS_DISABLE_DETERMINISTIC_UUIDS=YES 似乎暂时抑制了警告。

编辑 2016 年 2 月:

在最新版本的 Cocoapods 中,这已被移至 Podfile 的安装部分:install! 'cocoapods', :deterministic_uuids => false

我在添加应用程序扩展时遇到了这个错误。

我通过将我的应用程序目标中存在的 platform :ios, '7.0' 行也重复到我的新目标来修复它。

确保两个目标使用相同的平台解决了我的问题。

通过以下步骤为我解决了问题:(我也按照@ale0xB 的建议进行了更改)

  1. 清理项目
  2. 关闭Xcode
  3. 删除派生数据
  4. 如果您已经安装了 POD,请删除“.xcworkspace”和“Podfile.lock”文件
  5. 重新安装 pod
  6. 打开“.xcworkspace”并运行

这是不同目录下的重复文件造成的。 有时 Xcode 在 Xcode 的项目中通过拖动 将文件移动到另一个目录时 Xcode 可能会出错并复制文件 导航器(按 Command + 1 打开)。这些重复的文件是孤立的,没有被添加到 Xcode 项目中,所以一切正常。但是,pod install 接受了 Development Pods 中的所有文件,包括这些孤儿文件。

要找到这些重复的文件,我有如下两种解决方案,

解决方案 1

find . -path ./.git -prune -o -type f -exec basename {} + | sort | uniq -d

其中-path ./.git -prune -o表示查找

时排除.git目录

解决方案 2

  1. 将错误消息复制到一个名为 duplicateUUIDs.txt
  2. 的文本文件中
  3. 获取排序的文件名并输出重复项
grep -E '[a-zA-Z+]+\.(h|m|swift)' -o duplicateUUIDs.txt | sort | uniq -d

下一步

删除不需要的文件。

在 podfile 中写入此行 ==> 安装! 'cocoapods', :deterministic_uuids => 错误

例如: 平台:ios, '10.0' 安装! 'cocoapods', :deterministic_uuids => 错误

目标'WheeboxExamSheetScanner'做 配置 = use_native_modules!