1

我正在为一个开源库构建一个 pod,并且必须保持公共头文件的目录结构不变。简化的例子是这样的:

include/header1.h
include/foo/header2.h
src/file.c
src/internal.h

include目录包含公共标头。

我的 podspec 包含:

s.public_header_files = 'Foo/Classes/include/**/*'
s.private_header_files = 'Foo/Classes/src/internal.h'
s.header_mappings_dir = 'Foo/Classes/include'

项目Example编译良好,Pods/Headers/Public/Foo目录包含与原始目录相同的结构include

仍然pod lib lint Foo.podspec --use-libraries给我这个错误:

- ERROR | [iOS] header_mappings_dir: There are header files outside of the header_mappings_dir (Foo/Classes/src/internal.h)

出色地。是的。的确。但为什么这是一个错误?我完全适应这种情况。

我自己找到了一个解决方案,但我不确定它是否正确。

s.exclude_files = 'Foo/Classes/src/internal.h'

这使 linter 很高兴,并且项目仍然可以编译。但是感觉不对,因为文件是项目的一部分。

谢谢!

4

1 回答 1

2

我会自己回答这个问题。

exclude_filespodspec 推送到 git 服务器时,解决方法不起作用。

这个问题实际上是一个误解:不要使用其他路径规范来排除您在该source_files行中明确指定的文件!

解决方案是明确地将文件添加到source_files行中,这些文件要么是公共标头的一部分,要么应该在 Xcode 中获得编译规则。

通过header_mappings_dir_

s.preserve_paths = 'Foo/Classes/src/**/*'

现在一切正常。

于 2017-07-17T07:28:13.950 回答