如何从post_install挂钩中删除特定目标的pod链接?

时间:2017-08-03 09:29:09

标签: ios swift cocoapods

背景

  1. 使用CocoaPods进行所有依赖关系管理的现有iOS应用
  2. 添加了嵌入式Cocoa Touch框架(与扩展程序共享代码)
  3. 问题

    通过CocoaPods链接的一些库在框架和应用程序中都有“重复实现”。这会导致应用程序在任意选择要在运行时使用的实现时崩溃。

    这显然是CocoaPods中的一个错误,因为我的大多数依赖项链接并运行正常 - 只有一些问题(Firebase,Fabric,AppsFlyerFramework)。

    我是proposed尝试创建post安装挂钩以删除双链接的解决方案,但我不确定如何做到最好。

    如何通过post install hook轻松删除特定目标的依赖关系链接?我已经看到了一些这样的post_install个钩子,但这会删除一个特定的文件,而我需要删除整个pod链接。

    post_install do |installer|
        installer.pods_project.targets.each do |target|
            if target.name == 'Pods-Earthlings'
                source_files = target.source_build_phase.files
                dummy = source_files.find do |file|
                    file.file_ref.name == 'SomeDuplicate.m'
                end
                source_files.delete dummy
            end
        end
    end
    

0 个答案:

没有答案
相关问题