如何检查 Bundle.module 是否已定义?

How can I check if Bundle.module is defined?

在我的 iOS 应用程序中,我使用 SPM 来管理依赖项。其中之一是使用 Bundle.module 加载资源的库(Swift 5.3 中提供的一项新功能)。但现在我需要为我的应用程序使用 CocoaPods。因此,我应该为这种依赖添加 CocoaPods 支持。我知道我可以将 Bundle.module 的声明从 resource_bundle_accessor.swift 复制到库中。但它也应该支持SPM。我想知道如何检查我是否应该使用 resource_bundle_accessor.swift 中定义的 Bundle.module 或我的函数如果 resource_bundle_accessor.swift 没有生成。

一个选项是使用 #if SWIFT_PACKAGE 来区分 SPM 和 CocoaPods 特定代码。这是我们如何使用两个包管理器设置 运行 测试的示例:https://github.com/firebase/firebase-ios-sdk/blob/master/FirebaseRemoteConfig/Tests/Unit/RCNRemoteConfigTest.m#L1144