首页 > 解决方案 > 如何消除有关 MobileCoreServices 和 AssetsLibrary 的 Xcode 11.4 警告?

问题描述

升级到Xcode 11.4 beta后,我从Pods子项目(特别是来自YYImageBranch目标)收到了这些警告:

目标完整性:MobileCoreServices 已重命名。请改用 CoreServices。

目标完整性:不推荐使用 AssetsLibrary。考虑改为迁移到照片。

我有inhibit_all_warnings!我的Podfile,但它对那些没有影响。

有没有办法让这些警告静音,直到这些 pod 的创建者修复它们?

标签: xcodecocoapodsxcode11.4

解决方案


我注意到从Pods/Frameworks/iOS项目导航组中手动删除这两个框架可以解决这些警告。由于两个框架都嵌入到 iOS 本身(不是应用程序包)中,因此删除它们在运行时没有任何影响。以下是如何在Podfile安装后挂钩中自动执行此操作:

post_install do |installer|
    installer.pods_project.frameworks_group["iOS"]["MobileCoreServices.framework"].remove_from_project
    installer.pods_project.frameworks_group["iOS"]["AssetsLibrary.framework"].remove_from_project
end

如果这留下了悬挂(null)参考,您可以执行以下操作:

post_install do |installer|
    framework = installer.pods_project.frameworks_group["iOS"]["MobileCoreServices.framework"]
    framework.referrers.each do |ref|
        if ref.isa == "PBXBuildFile"
            ref.remove_from_project
        end
    end
    framework.remove_from_project
end

推荐阅读