在Cocoapods库中的编译中不包括源文件

Excluding source files from compilation in a CocoaPods library

本文关键字:不包括 源文件 编译 Cocoapods      更新时间:2023-10-16

我正在将库(unrar4ios)转换为使用可可录,但我遇到了汇编问题。大多数源文件是C 文件,其中一些文件未直接添加到项目"编译源"列表中,但是确实通过#include汇编了。当其中一个自行编译时,它会失败,因为它取决于 #include s it的文件(有点奇怪,我知道)。

简而言之,我需要将文件下载到PODS目录中,但随后不包括在库的目标中。据我所知,source_files PODSPEC同时控制。有没有一种方法可以纯粹在图书馆侧实现这一目标,而无需求助于客户端项目的podfile中的某些钩子?

我必须列出需要在source_files属性中明确编译的每个文件,并列出在preserve_paths属性中隐含构建所需的文件。喜欢:

Pod::Spec.new do |s|
  s.name          = "UnrarKit"
  ...
  s.source_files = "Classes/*.{mm,m,h}",
                   "Libraries/unrar/*.hpp",
                   "Libraries/unrar/archive.cpp",
                   "Libraries/unrar/arcread.cpp",
                   "Libraries/unrar/cmddata.cpp",
                   ...
                     # These files are built implicitly as dependencies
  s.preserve_paths = "Libraries/unrar/arccmt.cpp",
                     "Libraries/unrar/coder.cpp",
                     "Libraries/unrar/log.cpp",
                     ...