根据平台删除 Pod 依赖项



我正在向我的项目添加一个 apple watch 扩展,我想使用与我的主 iOS 应用程序相同的 pod。但是,我用于 iOS 应用程序的 podspec 有一个依赖项,当我在 podfile 中包含手表扩展作为目标时会导致错误。有没有办法删除基于平台(ios,watchos(的依赖项?

错误:

[!] The platform of the target `My Watch Extension` (watchOS 5.2) is not compatible with `Library X (10.1.19)`, which does not support `watchos`.

到目前为止,我正在我的 podfile 中执行以下操作:

target 'My Watch Extension' do
platform :watchos, '5.2'
pod 'MyPod', :path => 'MyPod'
end

我将以下内容添加到我的 podspec 中:

s.platforms = { :ios => "10.0", :watchos => "5.2"}

是否可以必须分离豆荚规格?

您可以为不同的平台设置不同的依赖项

spec.dependency 'Alamofire'
spec.ios.dependency 'Crashlytics'

这是我的pod文件的简化版本。 我只是为不同的目标包含不同的 pod。

def external_dependencies
pod 'Alamofire'
pod 'SQLite.swift/SQLCipher'
end
def caller_id_external_dependencies
pod 'GMCPagingScrollView'
pod 'KeychainAccess'
end
target 'Goob' do
external_dependencies
internal_dependencies
target 'UnitTests' do
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'SQLite.swift/SQLCipher'
inherit! :search_paths
end
end
target 'GoobCallerId' do
caller_id_external_dependencies
end

最新更新