gpt4 book ai didi

ios - Xcode 新构建系统 CocoaPods "Copy Pods Resources"在输出文件中有 Assets.car 并与 "Copy Bundle Resources"冲突

转载 作者:行者123 更新时间:2023-12-01 15:41:23 26 4
gpt4 key购买 nike

我们正在为我们的 Xcode 项目使用新的构建系统和 Cocoapods 1.7.5。我们的项目(我们称之为 Y)实际上是一个开发 pod,但我们也编写了一些代码来创建应用程序演示(您知道,为了加快构建和迭代速度)。这些演示代码( AppDelegate.swift 、启动任务等)不包含在开发 pod 中。剩余约 90% 的源代码和资源文件(例如 i18n 字符串和图像资源)被打包到开发 pod 中,供另一个项目(我们称之为 X)使用。
在开发过程中,大部分更改发生在 Y 的 dev pod 部分,因此我们需要确保 X 执行 pod install 时包含所有更改。 .
最近遇到一个问题:

error: Multiple commands produce '/Users/x/Library/Developer/Xcode/DerivedData/Y-cawteybtitmeiafweribgqzkuhnr/Build/Products/Debug-iphoneos/Y.app/Assets.car':
1) Target 'Y' (project 'Y') has compile command with input '/Users/name/DEV/workspace/Y/SupportFiles/Assets.xcassets'
2) That command depends on command in Target 'Y' (project 'Y'): script phase “[CP] Copy Pods Resources”
经过数小时的搜索 multiple commands produce assets.car在谷歌上,我们终于看到了一个似是而非的 explanation :

*.xcassets of Copy Bundle Resources --> Assets.car

*.xcassets of [CP] Copy Pods Resource --> other Assets.car

The first one covers second in the New Build System,That's the reason.


当我们手动删除 ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car来自 [CP] Copy Pods Resource 的输出文件,错误消失了,一切正常。然而,每当我们 git checkout到另一个分支,或 pod install , 或 pod update ,很有可能是 ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car再次出现在 [CP] Copy Pods Resource 的输出文件中.我们需要一次又一次地手动删除它,这既繁琐又令人沮丧。
然后我们开始质疑:这一切的幕后推手是谁?谁负责添加 ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car[CP] Copy Pods Resource 的输出文件?我们将目光聚焦在 Y.podspec并找到了这些行:
  s.resource_bundles = {
'Y' => ['Resources/*'], # assets, lottie etc.
'YAuto' => ['auto_resources/*'] # i18n strings etc.
}
我们以为我们正在使用 resource_bundles错了,所以我们又在谷歌上查了一下。令人惊讶的是,使用 resource_bundlesresourcesofficial documentation 推荐.此外,我们在 resource_bundles 方面没有发现任何不当使用。 ,让我们别无选择。
有人可以帮忙吗?我在想也许我们可以修补 Y.xcworkspacepost_install脚本在 Podfile ,但我不知道如何。

最佳答案

我通过写一个 post_install 解决了这个问题脚本在 Podfile它会自动删除这些 Assets.car .

post_install do |installer|
project_path = 'Y.xcodeproj'
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
build_phase = target.build_phases.find { |bp| bp.display_name == '[CP] Copy Pods Resources' }
assets_path = '${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car'
if build_phase.present? && build_phase.output_paths.include?(assets_path) == true
build_phase.output_paths.delete(assets_path)
end
end
project.save(project_path)
end

这似乎是一个 CocoaPods 错误,目前仍未修复。

关于ios - Xcode 新构建系统 CocoaPods "Copy Pods Resources"在输出文件中有 Assets.car 并与 "Copy Bundle Resources"冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58928768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com