适用于iOS和OSX的开发CocoaPod [英] Development CocoaPod for both iOS and OSX

查看:84
本文介绍了适用于iOS和OSX的开发CocoaPod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've got a CocoaPod published for iOS and want to make it available on OS X as well. I've fixed up my PodSpec so that it's ready for both iOS and 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期间,出现以下错误:

It's a simple pod that uses only Foundation classes, so it shouldn't need separate resources. All well and good, but during pod lib lint I get the following error:

 - 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的捆绑包?

It kind of makes sense, my EveryoneAPI.bundle target in the development section of Xcode is setup to create an iOS bundle. I can't for the life of me figure out how to get the pod to target OSX. Are there any good guides? Do I add a new target? If so, how do I tell the podspec to look for that specific bundle rather than the iOS one?

推荐答案

您可以添加

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

Podspec,就像我建议的那样,您应该指定源文件,并且pod lint错误是找不到源.

to your Podspec and like I'L'I suggested, you should specify the source file as well as your pod lint error is that it doesn't find the sources.

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

如果您的所有人API是模块,则也可以通过以下方式添加它:

If your everyoneAPI is a module, you can also add it this way :

s.osx.frameworks = 'everyoneAPI'

如果它是一个库,则可以通过以下方式添加它:

And if it's a library you can add it this way :

s.vendored_libraries = 'Vendor/everyoneAPI/everyoneAPI'

这篇关于适用于iOS和OSX的开发CocoaPod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆