无法将AFNetworking依赖项导入Cocoapod

时间:2015-03-22 04:19:40

标签: ios swift cocoapods podspec

我正在尝试为我的项目设置podspec,当我运行pod spec lint

时,我一直收到此错误
➭ pod spec lint

 -> BRECBathroomFinder (1.0.0)
    - ERROR | [iOS] Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - ERROR |  BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:16:26: error: use of undeclared type 'AFHTTPRequestOperationManager'
    - ERROR | [iOS]  BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:29:73: error: use of undeclared type 'AFHTTPRequestOperation'
    - ERROR | [iOS]  BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:48:35: error: use of undeclared type 'AFHTTPRequestOperation'
    - NOTE  | [iOS]  }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in
    - ERROR | [iOS]  BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:29:9: error: 'BBFOpenDataClient' does not have a member named 'GET'

Analyzed 1 podspec.

这是我的podspec。你会在底部注意到我的.prefix_header_contents = "#import <AFNetworking/AFNetworking.h>"在那里;所以我无法找到AFHTTPRequestOperation类。

Pod::Spec.new do |s| 
  s.name = "BRECBathroomFinder"
  s.version = "1.0.0"
  s.summary = "A pod that finds nearby BREC parks with restrooms"
  s.description = <<-DESC
                  This is a project built on top of Baton Rouge's Open Data API. It uses a query to find parks with bathrooms.

                  The results can be sorted according to how close the parks are to a given location or the user's location.
                  DESC
  s.homepage = "https://github.com/jmhooper/BRECBathroomFinder"
  s.author = { "Jonathan Hooper" => "jon9820@gmail.com"  }
  s.license = 'MIT'
  s.source = { git: "https://github.com/jmhooper/BRECBathroomFinder.git", tag: s.version.to_s }
  s.platform = :ios, '8.0'
  s.requires_arc = true
  s.source_files = "BRECBathroomFinder/**/*"
  s.dependency "AFNetworking", "~> 2.0"
  s.frameworks = "CoreLocation"
  s.prefix_header_contents = "#import <AFNetworking/AFNetworking.h>"
end

1 个答案:

答案 0 :(得分:4)

经过很多挫折之后,我终于明白了。

在它抱怨的文件中,我不得不添加import AFNetworking行以及我的其他Swift导入。

我做到了,podspec通过了验证。