ios - vendored_frameworks - podspec vendored_libraries




Cocoapods importing a framework to source code (2)

In my cocoapod for iOS, I have a essentially items:

  1. Open-source classes (.m & .h files)
  2. MyFramework.framework (.framework directory, header files, and .bundle for resources)

One of the open-source classes calls import <MyFramework.MyFramework.h> so it can use the components of MyFramework in its implementation. But because of this, I'm having trouble getting the podspec to pass the spec lint test (pod spec lint MyCocoapod.podspec). When I run the spec lint validation, it says:

ERROR | [iOS] [xcodebuild] .../MyFile.h:54:9: fatal error: 'MyFramework/MyFramework.h' file not found

While investigating, I noticed that the podspec does pass the spec lint validation if I remove that open-source class in the podspec's source_files section, s.source_files = 'MyFiles.{h,m}'. Any idea why my class can't import my custom framework during the spec lint validation?

The relevant code in the podspec looks like this:

s.preserve_paths      = 'myframework/MyFramework.framework'
s.frameworks          = 'Foundation', 'MyFramework'
s.xcconfig            = { 'FRAMEWORK_SEARCH_PATHS' => '$(SRCROOT)/myframework/' }
s.public_header_files = 'MyFramework.framework/Headers/*.h', 'SourceCode/*.h'
s.source_files        = 'SourceCode/*.{h,m}'  # Crashes here - Source_file imports MyFramework.h. If I take this out, it passes spec lint validation

EDIT This process is now entirely handled by the vendored_frameworks option. This handles preserving the paths, the framework search paths, and linking to the project.


To include a framework you can use:

s.vendored_frameworks = 'path/to/SomeFramework.framework'

To include bundle files do:

s.resources ='path/to/SomeBundle.bundle'





cocoapods