Search code examples
iosobjective-cxcodecocoapodspodspec

Podspec: Prefix import not found


My project is building ok. When I run pod spec lint I receive following error:

 - ERROR | [MyApp/Core] [xcodebuild]  Target Support Files/Pods-MyApp/Pods-MyApp-prefix.pch:6:9: fatal error: 'MyConstants.h' file not found

It's worth noticing the location of constants file: Project/Classes/MyConstants.h. Here is my podspec:

Pod::Spec.new do |spec|
  spec.name         = "AppName"
  spec.version      = "1.0"
  spec.summary      = "blah blah"
  spec.homepage     = "http://company.com/"
  spec.license      = 'Apache 2.0'
  spec.author       = { "me" => "me@company.com" }
  spec.source       = { :git => 'ssh://path', :tag => '1.0'}

  spec.requires_arc = true
  spec.ios.deployment_target = '7.0'
  spec.frameworks   = ['Foundation', 'UIKit', 'CoreGraphics', 'QuartzCore']

  spec.source_files = 'Classes/**.*', 'Classes/ViewControllers/**.*', 'Classes/Views/**.*'

  spec.prefix_header_contents = '#import "MyConstants.h"'

  spec.subspec 'Core' do |cs|
    cs.dependency 'libextobjc', '~> 0.4'
  end

end

I've also tried to exchange line:

spec.prefix_header_contents = '#import "MyConstants.h"'

with:

spec.prefix_header_file = 'MyApp/MyApp-Prefix.pch'

But the result is the same. What should I do to enable prefix to see source code?

--- EDIT ---

I've ended with refactoring all my source files. I've imported the classes which were needed manually, without using prefix. As so, this question was no longer important for me.


Solution

  • I had same issue. In the end I added ss.public_header_files in my subspec. Its more a work around which worked for me (I wouldnt call it a solution). according to docs:

    public_header_files
    
     A list of file patterns that should be used as public headers.    
    These are the headers that will be exposed to the user’s project
    and from which documentation will be generated. If no public
    headers are   specified then all the headers are considered public.
    


    Maybe its not entirely accurate.

    Edit
    My solution wasn't entirely correct. When I run the validation with pod lib lint it was successfully builded when I validate it with spec option I received the same error again.I ended up writing the question to cocaoPods team. .pch wont recognise included files