Development CocoaPod for both iOS and OSX

六眼飞鱼酱① 提交于 2019-12-22 05:25:14

问题


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

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

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?


回答1:


You can add

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

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}"

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'


来源:https://stackoverflow.com/questions/32086434/development-cocoapod-for-both-ios-and-osx

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