xcode Cocoapod pod 仅适用于指定平台

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33203319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:04:24  来源:igfitidea点击:

Cocoapod pod only for a specified platform

iosxcodecocoapodstvos

提问by Glenn Howes

I have an Xcode project with multiple targets. One of those targets targets the tvOS platform. My other targets make use of the 'youtube-iso-player-helper' framework, which does not support tvOS. I want to have a Cocoapod Podfile that includes the player framework only on iOS.

我有一个包含多个目标的 Xcode 项目。其中一个目标针对 tvOS 平台。我的其他目标使用不支持 tvOS 的“youtube-iso-player-helper”框架。我想要一个 Cocoapod Podfile,它只包含 iOS 上的播放器框架。

Here is my current Podfile:

这是我当前的 Podfile:

source 'https://github.com/CocoaPods/Specs.git' 
platform :ios, '8.0'
platform :tvos, '9.0'

use_frameworks!

pod 'SVGgh'

pod "youtube-ios-player-helper", "~> 0.1"

xcodeproj 'MyProject.xcodeproj'

When I try to update my pods, I get the following error:

当我尝试更新 Pod 时,出现以下错误:

[!] The platform of the target Pods(tvOS 9.0) is not compatible with youtube-ios-player-helper (0.1.4), which does not support tvos.

[!] 目标平台Pods(tvOS 9.0)不兼容youtube-ios-player-helper (0.1.4),不支持tvos.

Obviously, this is using the current version of Cocoapods.

显然,这是使用当前版本的 Cocoapods。

So, I need to know the syntax required for my Podfile.

所以,我需要知道我的 Podfile 所需的语法。

回答by Claes

This seems to work for me:

这似乎对我有用:

target 'iOSAppTarget' do
  platform :ios, '8.0'
  pod 'PodForiOS'
end

target 'TVAppTarget' do
  platform :tvos, '9.0'
  pod 'PodForTV'
end

回答by TurboManolo

Just came across a similar problem and I've fixed it by using this pattern:

刚刚遇到了一个类似的问题,我已经使用这种模式修复了它:

source 'https://github.com/CocoaPods/Specs.git'  

def shared_pods
    pod 'SVGgh'
end

target 'myiOSTargetName' do
    platform :ios, '8.0'
    use_frameworks! 
    shared_pods
    pod "youtube-ios-player-helper", "~> 0.1"
end

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

I haven't tested it but I hope it helps! Cheers

我还没有测试过,但我希望它有帮助!干杯

回答by CodyMace

It's actually not just you podfile, but the creator of the pod needs to enable apple TV. You can read about it here http://blog.cocoapods.org/CocoaPods-0.39/

其实不只是你这个podfile,pod的创建者需要启用apple TV。你可以在这里阅读它http://blog.cocoapods.org/CocoaPods-0.39/

回答by Dima Cheverda

I have similar problem, but with framework. Try to use targetand link_withto install pod for specific target:

我有类似的问题,但有框架。尝试使用targetlink_with安装特定目标的 pod:

target :tvos, :exclusive => true do
    use_frameworks!
    link_with 'AppName'
    pod "youtube-ios-player-helper", "~> 0.1"
end