运行“pod spec lint”时出现“错误:预期类型”错误

Posted

技术标签:

【中文标题】运行“pod spec lint”时出现“错误:预期类型”错误【英文标题】:"error: expected a type" error when running "pod spec lint" 【发布时间】:2016-01-08 11:20:41 【问题描述】:

我正在尝试将现有项目转换为 cocoapod,以便在运行时更容易使用

pod spec lint --verbose

我收到许多类似于

的错误

- ERROR | [ios] xcodebuild: CoreDataServices/CoreDataServices/Services/Count/CDSCountService.m:28:9: error: use of undeclared identifier 'NSFetchRequest'

我的 podspec 如下:

 Pod::Spec.new do |s|

  s.name         = "CoreDataServices"
  s.version      = "0.2.0"
  s.summary      = "CoreDataServices contains a set of helper classes to abstract away common core data functionality."

  s.homepage     = "http://www.williamboles.me"
  s.license      =  :type => 'MIT', 
                     :file => 'LICENSE.md' 
  s.author       = "William Boles"

  s.platform     = :ios, "8.0"

  s.source       =  :git => "https://github.com/wibosco/CoreDataServices.git", 
                     :branch => "master", 
                     :tag => s.version 

  s.source_files  = "CoreDataServices/**/*.h,m"
  s.public_header_files = "CoreDataServices/**/*.h"

  s.frameworks = 'UIKit', 'CoreData'

  s.requires_arc = true

end

我安装了 cocoapod 0.39.0 版。

在 cocoapods 之外使用 xcodebuild 构建项目会导致项目构建时没有错误。

【问题讨论】:

【参考方案1】:

我最终设法到达了那里,但这很奇怪:

Pod::Spec.new do |s|

  s.name         = "CoreDataServices"
  s.version      = "0.2.0"
  s.summary      = "CoreDataServices contains a set of helper classes to abstract away common core data functionality."

  s.homepage     = "http://www.williamboles.me"
  s.license      =  :type => 'MIT', 
                     :file => 'LICENSE.md' 
  s.author       = "William Boles"

  s.platform     = :ios, "8.0"

  s.source       =  :git => "https://github.com/wibosco/CoreDataServices.git", 
                     :branch => "master", 
                     :tag => s.version 

  s.source_files  = "CoreDataServices/**/*.h,m"
  s.public_header_files = "CoreDataServices/**/*.h"

  s.requires_arc = true

  s.frameworks = 'UIKit', 'CoreData'

end

我将s.requires_arc = true 移到s.framework = 'UIKit', 'CoreData' 上方,错误就消失了。

我还注意到,如果我颠倒框架的顺序,它就会变成

s.frameworks = 'CoreData', 'UIKit'

s.requires_arc = true 

这也有效

【讨论】:

以上是关于运行“pod spec lint”时出现“错误:预期类型”错误的主要内容,如果未能解决你的问题,请参考以下文章

Cocoapod“pod spec lint”CompileSwift返回了一个不成功的退出代码

pod spec lint - 获取 xcodebuild 注释

无法在某些本地化上通过 pod spec lint 验证

pod spec lint 错误:无法构建模块“Protobuf”,找不到文件:#import "google/protobuf/Any.pbobjc.h"

部署 Google App Engine 应用程序时出现 503 错误

在运行SQL时出现错误,请问如何解决?