Question

I'm trying to create a podspec for a library that has a source file which contains a TARGET_OS_IPHONE conditional. The linting reports errors

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'

Here is the 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

and here is the line in the source code that is apparently causing the error:

#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

I'm using Cocoapods v.0.19.1, so why is this error be thrown and how can I fix it?

Was it helpful?

Solution

It looks like you're importing a file on OS X that attempts to use that property. Specifically YapDatabase/YapDatabase/Abstract/YapAbstractDatabaseConnection.m. Since this property isn't declared on OS X it cannot find it. Which explains the error:

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

On the lines it also shows in the error:

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

To fix this you'll want to look at exclude_files which you can use platform specific with something like:

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

Although just excluding this single file may not work since other files may need this as well. This really depends on how your code is setup though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top