如何为少数平台创建库 Pod?

How to create library Pod for few platforms?

我要为多个平台(比如说 iOSOSX)创建我自己的 Cocoapod,因为它没有严格的平台依赖性。为此,我在 .podspec 文件中未指定 s.platform。当尝试使用 pod lib lint 对其进行 lint 时,出现错误:

- ERROR | [tvOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE  | [tvOS] xcodebuild:  xcodebuild: error: SDK "appletvsimulator" cannot be located.

显然它尝试为 tvOS 平台构建但失败了。我用谷歌搜索了一下这个问题,但我没有找到任何东西。

有什么解决办法吗?实际上我不需要为 tvOS 测试构建,所以我如何设置 osx 和 ios 仅支持。

PS。 XCode7.0.1

我不确定这是否正确,但它对我有用。 只需在 .podspec 文件中使用多个平台声明:

s.platform = :ios
s.platform = :osx

可能还有部署目标声明:

s.ios.deployment_target = "5.0"
s.osx.deployment_target = "10.7"

此外,由于库支持多个平台,您需要根据 'Base SDK' 为 'Pods' 选择。

如果您要针对 iOS 和 tvOS,这就是一个示例。

Pod::Spec.new do |s|

s.name        = 'SVGgh'
s.version     = '1.5.1'
s.license     = 'MIT'
s.tvos.deployment_target = '9.0'
s.ios.deployment_target = '7.0'

s.summary     = "SVG Rendering Library for iOS"
s.homepage = 'https://github.com/GenerallyHelpfulSoftware/SVGgh'
s.source   = { :git => 'https://github.com/GenerallyHelpfulSoftware/SVGgh.git', :tag => "v1.5.1" }

s.ios.source_files = 'SVGgh/**/*{.h,m}'
s.tvos.source_files = 'SVGgh/**/*{.h,m}'
s.framework = 'CoreGraphics', 'CoreImage', 'CoreText', 'UIKit', 'Foundation'
s.prefix_header_file = 'SVGgh/SVGgh-Prefix.pch'
s.requires_arc = true
end

我认为这需要将 Cocoapods 库更新到 0.39 或更高版本。请注意,您可以为每个平台选择一组不同的源文件。

[已更新以回应表明提问者不想要 tvOS 的评论。]。