警告构建:运行脚本构建阶段“模块”将在每次构建期间运行,因为它未指定任何输出。为了解决这个警告

Jak*_*cki 42 xcode

我收到一些集成到我的工作区中的框架/模块的错误。

警告构建:运行脚本构建阶段“模块名称”将在每次构建期间运行,因为它未指定任何输出。要解决此警告,请将输出依赖项添加到脚本阶段,或者通过取消选中脚本阶段中的“基于依赖项分析”将其配置为在每个构建中运行。

我正在寻找有关如何解决该问题的解决方案。

要解决此警告...或通过在脚本阶段取消选中“基于依赖关系分析”将其配置为在每个构建中运行。

我不想使用上述解决方案,因为这会花费我的构建时间。我宁愿知道下面该怎么做:

...将输出依赖项添加到脚本阶段

不幸的是我对如何做到这一点没有足够的知识。我在网上搜索了一下,没有找到具体的信息。

如何输出这些依赖关系?谢谢

Dar*_*ust 12

有关详细信息,请参阅脚本阶段文档,尤其是“为脚本指定输入和输出文件”部分。您需要编辑构建阶段并指定脚本使用哪些文件作为输入(如果有)以及将生成哪些文件。

使用此信息,Xcode 构建过程可以确定是否需要运行脚本阶段:如果输入文件未更改,则根本不需要运行脚本阶段。如果它确实运行,Xcode 至少知道生成了哪些输出文件,从而知道需要运行哪些取决于这些文件的其他构建过程。

另请参阅提高增量构建的速度中的“声明自定义脚本和构建规则的输入和输出”部分


Rog*_*Oba 10

如果您使用 CocoaPods,您的警告主要来自它。我为此想出了两个临时解决方案,即修改 Podfile。永久解决方案需要直接在 CocoaPods 本身中解决该问题。对于不是由 CocoaPods 生成的自定义运行脚本,只需取消选中“基于依赖关系分析”即可向 Xcode 表明您故意没有输入/输出文件来确定是否应该运行该脚本。

\n

两者都在需要时在任何给定项目 <=> 目标对上将always_out_of_date(又名“基于依赖性分析”)标志设置为 true ( )。"1"

\n

post_integrate解决方案 A:在钩子中完成这一切

\n

优点:单块、紧凑的解决方案

\n

缺点:运行时性能低于解决方案 B pod install,但老实说,它是不可察觉的。

\n
# Fix Xcode 14 warnings like:\n# warning: Run script build phase \'[CP] Copy XCFrameworks\' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target \'ATargetNameHere\' from project \'YourProjectName\')\n# Ref.: https://github.com/CocoaPods/CocoaPods/issues/11444\npost_integrate do |installer|\n  main_project = installer.aggregate_targets[0].user_project\n  pods_project = installer.pods_project\n  targets = main_project.targets + pods_project.targets\n  targets.each do |target|\n    run_script_build_phases = target.build_phases.filter { |phase| phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) }\n    cocoapods_run_script_build_phases = run_script_build_phases.filter { |phase| phase.name.start_with?("[CP]") }\n    cocoapods_run_script_build_phases.each do |run_script|\n      next unless (run_script.input_paths || []).empty? && (run_script.output_paths || []).empty?\n      run_script.always_out_of_date = "1"\n    end\n  end\n  main_project.save\n  pods_project.save\nend\n
Run Code Online (Sandbox Code Playgroud)\n

解决方案B:与A相同,只是修改了hookpods_project内的内容post_install,以获得稍微更好的性能

\n

优点:技术上比解决方案 A 性能更高,因为它节省了一次昂贵的调用xcodeproj.save

\n

缺点:解决方案在您的 Podfile 中更加分散。

\n
# Fix Xcode 14 warnings like:\n# warning: Run script build phase \'[CP] Copy XCFrameworks\' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target \'ATargetNameHere\' from project \'YourProjectName\')\n# Ref.: https://github.com/CocoaPods/CocoaPods/issues/11444\ndef set_run_script_to_always_run_when_no_input_or_output_files_exist(project:)\n  project.targets.each do |target|\n    run_script_build_phases = target.build_phases.filter { |phase| phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) }\n    cocoapods_run_script_build_phases = run_script_build_phases.filter { |phase| phase.name.start_with?("[CP]") }\n    cocoapods_run_script_build_phases.each do |run_script|\n      next unless (run_script.input_paths || []).empty? && (run_script.output_paths || []).empty?\n      run_script.always_out_of_date = "1"\n    end\n  end\n  project.save\nend\n\npost_integrate do |installer|\n  main_project = installer.aggregate_targets[0].user_project\n  set_run_script_to_always_run_when_no_input_or_output_files_exist(project: main_project)\nend\n\npost_install do |installer|\n  installer.pods_project.targets.each do |target|\n    # Projects usually do stuff in here\xe2\x80\xa6\n  end\n  set_run_script_to_always_run_when_no_input_or_output_files_exist(project: installer.pods_project)\nend\n
Run Code Online (Sandbox Code Playgroud)\n
\n

运行后pod install,如果您的 xcodeproj 文件存储在 git 中,请提交对主 xcodeproj 所做的更改。

\n