【问题标题】:How to use same pods for iOS and tvOS?如何为 iOS 和 tvOS 使用相同的 pod?
【发布时间】:2019-10-15 12:34:02
【问题描述】:

我想为 iOS 和 tvOS 使用相同的 pod。为此,我在 pod 文件中编写了这样的代码,

def shared_pods
    pod 'Moya', '~> 9.0' #Alamofire wrapper
    pod 'AlamofireNetworkActivityLogger', '~> 2.0'
    pod 'AlamofireObjectMapper'
    pod 'ReachabilitySwift', '~> 4.0'
    pod 'SDWebImage', '~> 4.4.5'

end

target 'iosApp' do
  platform :ios, '9.0'
  use_frameworks!
  inhibit_all_warnings!
  shared_pods

end

target 'TVApp' do
    platform :tvos, '9.0'
    use_frameworks!
    inhibit_all_warnings!
    shared_pods
end

但我得到错误The platform of the target TVApp (tvOS 9.0) is not compatible with Stripe, which does not support tvOS.

其他吊舱,例如, pod 'DynamicCodable' pod 'Stripe', '~> 15.0.1' pod 'GooglePlacesSearchController' pod 'Google-Mobile-Ads-SDK' pod 'NTMonthYearPicker' pod 'NYTPhotoViewer', '~> 1.1.0' pod 'MGSwipeTableCell' pod 'SendBirdSDK', '~> 3.0' pod 'FLAnimatedImage' pod 'RSKImageCropper' #tappable label pod 'ActiveLabel' #calendar pod 'FSCalendar' #Location pod 'GooglePlaces' pod 'CreditCardValidator' pod 'FittedSheets' pod 'Branch' pod 'CarbonKit' pod 'AWSS3' 也与 tvOS 不兼容,但我想在 tvOS 中使用。

如何在两个操作系统上使用相同的框架?

【问题讨论】:

标签: ios swift cocoapods tvos


【解决方案1】:

Moya pod 与 tvOS 兼容,您可以在其 .podspec file 中看到:

  s.tvos.deployment_target = '9.0'

我尝试使用您的 .podspec 配置运行项目,但遇到过时的 Moya 子依赖项 "Result", "~> 3.0" 的问题。但是,在上一个版本中,此依赖已更新为 "Result", "~> 4.1",并且我能够在 iOS 9.0 tvOS 上成功运行 Moya。

尝试使用最新版本:

def shared_pods
    pod 'Moya', '13.0.1' #Alamofire wrapper
    pod 'AlamofireNetworkActivityLogger', '~> 2.0'
    pod 'AlamofireObjectMapper'
    pod 'ReachabilitySwift', '~> 4.0'
    pod 'SDWebImage', '~> 4.4.5'
end

编辑

但是,正如您在编辑中提到的,您的所有其他 pod 依赖项都与 tvOS 不兼容:

[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `DynamicCodable (1.0)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `Stripe (15.0.1)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `GooglePlacesSearchController (0.2.1)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `Google-Mobile-Ads-SDK (7.41.0)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `NTMonthYearPicker (1.0.0)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `FLAnimatedImage (1.0.12)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `NYTPhotoViewer (1.1.0)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `MGSwipeTableCell (1.6.9)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `SendBirdSDK (3.0.154)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `RSKImageCropper (2.2.3)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `ActiveLabel (1.0.1)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `FSCalendar (2.8.0)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `GooglePlaces (3.5.0)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `CreditCardValidator (0.4)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `FittedSheets (1.4.5)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `Branch (0.29.1)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `CarbonKit (2.3.1)`, which does not support `tvOS`.
[!] The platform of the target `tvApp` (tvOS 9.0) is not compatible with `AWSS3 (2.12.0)`, which does not support `tvOS`.

要检查兼容性,您可以打开 pod 存储库并检查 .podspec 文件。例如,Stripe .podspec 没有 tvos.deployment_target

您不能使用与项目目标不兼容的框架。

【讨论】:

  • 该问题清楚地表明,作者在运行 Stripe 和其他不兼容的 pod 与 tvOS 时遇到问题,而不是在 tvOS 上运行任何特定版本的 pod,这使您的回答关于特定的 pod Moya 有点跑题了。
  • @denis_lor 不,问题的标题暗示了这一点,但问题的内容表明问题是特定的 pod。所以这个答案很好。
  • 可能是,我们需要作者提供更多细节
  • 我在编辑之前开始回答,然后 OP 将 Moya 更改为 Stripe 并添加了其他不兼容的 Pod。我编辑了答案。
【解决方案2】:

来自Stripe 文档https://stripe.com/docs/mobile/ios 它说:

该库与iOS 9.0 及更高版本兼容

这就是为什么它不适用于您的 tvos 平台目标。

【讨论】:

  • 您对在您的tvOS 平台目标中使用诸如Stripe 之类的库有疑问吗?我认为您的问题与此有关,因为我看到您特别包含有关 Stripe 的错误。我了解您可能希望在您的tvOS 平台目标以及您列出的其他 pod 中使用,但特别是您遇到错误的那个,Stripe,与tvOS 不兼容。对于其他人,您只需访问他们的网站/cocoapods 链接/github 页面,看看他们是否支持。
【解决方案3】:

我认为错误很明显? “目标 TVApp(tvOS 9.0)的平台与不支持 tvOS 的 Stripe 不兼容。” Stripe 似乎无法在 tvOS 上运行,这意味着您无法使用它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    • 2016-04-14
    • 2020-01-21
    • 1970-01-01
    • 2017-09-06
    • 1970-01-01
    相关资源
    最近更新 更多