Reputation: 94
I'm building a pod for an open source library and have to leave the directory structure for the public header files intact. The simplified example is this:
include/header1.h
include/foo/header2.h
src/file.c
src/internal.h
The include
directory contains the public headers.
My podspec contains:
s.public_header_files = 'Foo/Classes/include/**/*'
s.private_header_files = 'Foo/Classes/src/internal.h'
s.header_mappings_dir = 'Foo/Classes/include'
The Example
project compiles fine and the Pods/Headers/Public/Foo
directory contains the same structure as the original include
directory.
Still pod lib lint Foo.podspec --use-libraries
gives me this error:
- ERROR | [iOS] header_mappings_dir: There are header files outside of the header_mappings_dir (Foo/Classes/src/internal.h)
Well. Yes. Indeed. But why is this an error? I am totally fine with the situation.
I have found a solution myself, but I'm not sure if it is the correct one.
s.exclude_files = 'Foo/Classes/src/internal.h'
This makes the linter happy and the project still compiles. But it feels wrong, because the file is part of the project.
Upvotes: 2
Views: 852
Reputation: 94
I'll answer this myself.
The exclude_files
workaround did not work, when pushing the podspec to a git server.
The problem was actually a misconception: do not use the other path specification to exclude files you explicetely specified in the source_files
line!
The solution was to explicitely only add the files to the source_files
line, that are either part of the public headers or should get a compile rule in Xcode.
Any other files (headers outside of the header_mappings_dir
and .c files that should be included but not compiled on their own) are added via
s.preserve_paths = 'Foo/Classes/src/**/*'
Now everything works.
Upvotes: 3