Cocoapod pod only for a specified platform

微笑、不失礼 提交于 2019-12-14 01:12:42

问题


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.

Here is my current 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:

[!] 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.

Obviously, this is using the current version of Cocoapods.

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


回答1:


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



回答2:


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

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



回答3:


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




回答4:


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/



来源:https://stackoverflow.com/questions/33203319/cocoapod-pod-only-for-a-specified-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!