【问题标题】:Podspec linting fails on TARGET_OS_IPHONE conditionalPodspec linting 在 TARGET_OS_IPHONE 条件下失败
【发布时间】:2013-05-07 23:41:43
【问题描述】:

我正在尝试为具有包含 TARGET_OS_IPHONE 条件的源文件的库创建 podspec。 linting 报告错误

YapDatabase (1.2.1)
    - ERROR | [OSX] [xcodebuild]  
YapDatabase/YapDatabase/Abstract/YapAbstractDatabaseConnection.m:78:8: 
error: property 'autoFlushMemoryLevel' not found on object of type 
'YapAbstractDatabaseConnection *'
    - ERROR | [OSX] [xcodebuild]  
YapDatabase/YapDatabase/Abstract/YapAbstractDatabaseConnection.m:398:30: error: 
no visible @interface for 'YapAbstractDatabaseConnection' declares the selector 
'autoFlushMemoryLevel'

这是 podspec:

Pod::Spec.new do |s|
  s.name         = "YapDatabase"
  s.version      = "1.2.1"
  s.summary      = "A key/value store built atop sqlite for iOS & Mac."

  s.homepage     = "https://github.com/yaptv/YapDatabase"



  s.license      = 'MIT'



  s.author       = { "yaptv" => "yaptv@yaptv.com" }

  s.source       = { :git => "https://github.com/yaptv/YapDatabase.git", :tag => "1.2.1" }



  s.ios.deployment_target = '6.0'
  s.osx.deployment_target = '10.75'


  s.source_files = 'YapDatabase/**/*.{h,m}','Vendor/**/*.{h,m}'
  s.exclude_files = 'YapDatabase/Testing'


  s.public_header_files = 'YapDatabase/Key_Value/YapDatabase.h'


  s.requires_arc = true


end

这是源代码中明显导致错误的行:

#if TARGET_OS_IPHONE
/**
 * When a UIApplicationDidReceiveMemoryWarningNotification is received,
 * the code automatically invokes flushMemoryWithLevel and passes this set level.
 * 
 * The default value is YapDatabaseConnectionFlushMemoryLevelMild.
 * 
 * @see flushMemoryWithLevel:
**/
@property (atomic, assign, readwrite) int autoFlushMemoryLevel;
#endif

我使用的是 Cocoapods v.0.19.1,那么为什么会抛出这个错误,我该如何解决呢?

【问题讨论】:

    标签: ios objective-c lint cocoapods targeting


    【解决方案1】:

    看起来您正在尝试使用该属性的 OS X 上导入文件。特别是YapDatabase/YapDatabase/Abstract/YapAbstractDatabaseConnection.m。由于此属性未在 OS X 上声明,因此无法找到它。这解释了错误:

    no visible @interface for 'YapAbstractDatabaseConnection' declares the selector 'autoFlushMemoryLevel'
    

    它也显示在错误中:

    ERROR | [OSX] [xcodebuild]  YapDatabase/YapDatabase/Abstract/YapAbstractDatabaseConnection.m:78:8:
    ERROR | [OSX] [xcodebuild]  YapDatabase/YapDatabase/Abstract/YapAbstractDatabaseConnection.m:398:30
    

    要解决此问题,您需要查看exclude_files,您可以使用特定于平台的内容,例如:

    s.osx.exclude_files = 'path/to/files'
    

    虽然仅仅排除这个单个文件可能不起作用,因为其他文件也可能需要它。不过,这实际上取决于您的代码是如何设置的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-18
      • 2013-09-16
      • 2016-03-10
      • 2019-02-17
      • 2017-04-27
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多