cocoapods – 挂钩Podfile以编辑我的项目文件

我想修复 Cocoapods的bug,它为Extension目标添加了Embed Pods Frameworks构建阶段.那里不需要这些阶段.

https://github.com/CocoaPods/CocoaPods/issues/4203

我写了脚本来删除它

puts "Deleting not needed phases…"
project_path = "Keyboard.xcodeproj"
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
    if target.name.include?("Extension")
        phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
        if !phase.nil?
            puts "Deleting Embed Pods Frameworks phase…"
            target.build_phases.delete(phase)
        end
    end
end

project.save

我可以在手动安装pod后运行此脚本,但我想以某种方式将其添加到Podfile.它在post_install钩子中不起作用

post_install do |installer|
    ...
end

因为UserProjectIntegrator.integrate!在post_install之后调用,它会覆盖我的更改.

有没有办法在Podfile中集成这个脚本?

最佳答案 最简洁的答案是不.

答案很长:

从pod install –verbose的输出中,构建阶段Embed Pods Frameworks添加到集成客户端项目中,该项目在Podfile中的post_install步骤之后运行.

这就是您应该在pod安装完成后单独执行此脚本的原因.

点赞