为iOS和OSX开发CocoaPod

时间:2015-08-19 04:12:22

标签: ios macos cocoapods podspec

我已经为iOS发布了一个CocoaPod,并希望在OS X上也可以使用它。我修复了我的PodSpec,以便它可以用于iOS和Mac OS X:

Pod::Spec.new do |s|
  s.name             = "EveryoneAPI"
  s.version          = "0.9.5"
  s.summary          = "An objective-c wrapper for EveryoneAPI.com's API"
  s.description      = <<-DESC
                       To retrieve all information for EveryoneAPI use the following:
                            EveryoneAPI *everyoneAPI = [[EveryoneAPI alloc] initWithAccountSID:@"ACb8444c3013dc40518e46b48c91f82ba0" withAuthToken:@"AUe90abecac85645ca8a314d41e9b55079"];

                            [everyoneAPI getInformation:EveryoneAPIReturnAllInfo forPhoneNumber:@"5551234567" withSuccessHandler:^(EveryoneAPIResponseObject *responseObject){
                                } withErrorHandler:^(NSError *error, NSNumber *statusCode, NSString *readableError){
                            }];
                       DESC
  s.homepage         = "https://github.com/msencenb/EveryoneAPI"
  s.license          = 'MIT'
  s.author           = { "Matt Sencenbaugh" => "my_email@gmail.com" }
  s.source           = { :git => "https://github.com/msencenb/EveryoneAPI.git", :tag => s.version.to_s }

  s.ios.deployment_target = "8.0"
  s.osx.deployment_target = "10.9"
  s.requires_arc = true

  s.source_files = 'Pod/Classes'
  s.resource_bundles = {
    'EveryoneAPI' => ['Pod/Assets/*.png']
  }
end

这是一个只使用Foundation类的简单pod,因此它不需要单独的资源。一切都很好,但在pod lib lint期间,我收到以下错误:

 - NOTE  | [OSX]  error: /var/folders/yd/kfjb5s4d1vv57fv5lhtm9lbh0000gn/T/CocoaPods/Lint/build/Release/EveryoneAPI.bundle: No such file or directory

这有点意义,Xcode开发部分中的EveryoneAPI.bundle目标设置为创建iOS包。我不能为我的生活弄清楚如何让pod定位到OSX。有什么好的指南吗?我是否添加了新目标?如果是这样,我如何告诉podspec寻找特定的捆绑而不是iOS?

1 个答案:

答案 0 :(得分:4)

您可以添加

s.platform = :osx, '10.7'
s.platform = :ios, '6.0'

到你的Podspec并且像我建议的那样,您应该指定源文件以及pod lint错误,因为它找不到源。

s.osx.source_files = "Classes/osx/**/*.{h,m}"

如果您的everyoneAPI是一个模块,您也可以这样添加:

s.osx.frameworks = 'everyoneAPI'

如果它是一个库你可以这样添加它:

s.vendored_libraries = 'Vendor/everyoneAPI/everyoneAPI'