使用 C++ 并作为框架编译的 Cocoapods 规范

Cocoapods spec that uses C++ and compiles as a framework

快速总结:如何将 Xcode 分发的 header 的包含路径添加到 .podspec.json 文件?

我正在开发一个 Swift 项目,我想在其中将 AudioKit 作为依赖项包含在内。对于这个项目,我必须在我的 Podfile

中添加 'use_frameworks!'

所以我在 Podfile 中添加了我的 Pod(主仓库还没有更新,这就是为什么我直接指向 github 仓库)

pod 'AudioKit', :git => 'https://github.com/niklassaers/AudioKit.git'

并添加我的 Swift 个文件

import AudioKit

然后我的编译器会警告我 CsoundFile.hpp 正在引用无法找到的 iostreamiostream.h 在:

/Applications/Xcode62.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/backward/iostream.h

与 stdlib.h 相比:

/Applications/Xcode62.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdlib.h

如何将此 header 目录添加到 AudioKit.podspec.json 中的搜索路径(我已分叉)。

我做了一个示例项目来演示我在上面写的内容:https://github.com/niklassaers/AudioKitSwiftFrameworkError - 你可以下载它并编译它,你会看到错误消息。

这里的主要问题是 AudioKit.podspec.json 缺少 public header 定义。所以所有 headers 都被认为是 public,包括 C++ headers.

因为没有来自 Objective-C class header 的传递性导入,如果只声明 public:

,它应该仍然有效
"public_header_files": [
  "AudioKit/Core Classes/**/*.h",
  "AudioKit/Instruments/**/*.h",
  "AudioKit/Notes/**/*.h",
  "AudioKit/Operations/**/*.h",
  "AudioKit/Parameters/**/*.h",
  "AudioKit/Sequencing/**/*.h",
  "AudioKit/Tables/**/*.h",
  "AudioKit/Utilities/**/*.h"
],
…
"osx": {
   …
   "public_header_files": ["AudioKit/Platforms/OSX/classes/*.h"]
}
"ios": {
   …
   "public_header_files": ["AudioKit/Platforms/iOS/classes/*.h"]
}