CocoaPod-在头文件中使用C ++时Podspec掉毛错误

时间:2018-09-12 11:10:46

标签: c++ ios cocoapods podspec

当插入头文件包括C ++时出现问题。

pod lib lint MyLibrary.podspec

这是我的头文件声明:

#include <memory>
#include <string>
#include <vector>
#include <stdexcept>

我收到以下错误 PathToMyHeader:31:10:致命错误:找不到“内存”文件

我认为'string','vector','stdexpept'将是相同的错误

这是我的podspec

  s.source_files = 'Pod/Classes/Include/*', 'Pod/Frameworks/MyFramework.framework/Headers/*.h'

  s.resource_bundles = {
      'Pod' => ['Pod/Resources/*']
  }

  s.public_header_files = 'Pod/Frameworks/MyFramework.framework/Headers/*.h'
  s.vendored_frameworks = 'Pod/Frameworks/MyFramework.framework'
  s.frameworks = 'Accelerate', 'Security', 'QuartzCore', 'OpenGLES', 'CoreBluetooth', 'CoreGraphics', 'CoreFoundation', 'CoreText', 'MyFramework'
  s.vendored_libraries = 'Pod/Libraries/*.a'
  s.libraries = 'z', 'stdc++', 'MyLib'
  s.pod_target_xcconfig = {
      'CLANG_CXX_LANGUAGE_STANDARD' => 'compiler-default',
      'CLANG_CXX_LIBRARY' => 'libc++',
      'OTHER_LDFLAGS' => '$(inherited) -ObjC'
  }

掉毛后的错误

While building module 'MyPod' imported from /var/folders/mg/0ckz5wr564sf3ctkr_lbtt440000gn/T/CocoaPods-Lint-20180913-4902-prtn4r-MyPod/App/main.m:3:
    In file included from <module-includes>:1:
    In file included from /Users/xxx/Library/Developer/Xcode/DerivedData/App-gtcyhyyxmkxxbbfdxoqxlqrpwaaq/Build/Products/Release-iphonesimulator/MyPod/MyPod.framework/Headers/MyPod-umbrella.h:22:
    /Users/xxx/Library/Developer/Xcode/DerivedData/App-gtcyhyyxmkxxbbfdxoqxlqrpwaaq/Build/Products/Release-iphonesimulator/MyPod/MyPod.framework/Headers/Header-cpp.h:30:10: fatal error: 'memory' file not found
    #include <memory>
             ^~~~~~~~
    94 warnings and 1 error generated.
    /var/folders/mg/0ckz5wr564sf3ctkr_lbtt440000gn/T/CocoaPods-Lint-20180913-4902-prtn4r-MyPod/App/main.m:3:9: fatal error: could not build module 'MyPod'
    @import MyPod;
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
    94 warnings and 2 errors generated.

    ** BUILD FAILED **

更新09/13/2018 @Paul Beusterien,非常感谢您对我的帮助,它现在可以正常工作。 吊舱使用:

pod lib lint MyPodSpec.podspec --skip-import-validation

但是在我为工作场所中的项目调用pod install之后,它似乎刚刚通过了pod,但是在运行项目时显示相同的错误 Error

2 个答案:

答案 0 :(得分:1)

无法清理C ++标头是known CocoaPods issue

解决方法是选择--skip-import-validation

答案 1 :(得分:0)

将c ++头文件添加到私有头组。

使用podspec,您可以像这样添加

spec.private_header_files = 'Headers/Private/*.h'

在专用头文件中,您可以安全地包含stdlib头