【问题标题】:CocoaPod - Podspec linting errors when using C++ in header filesCocoaPod - 在头文件中使用 C++ 时的 Podspec linting 错误
【发布时间】:2019-02-17 00:17:20
【问题描述】:

linting 头文件包含 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'
  }

linting 后的错误

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 **

2018 年 9 月 13 日更新 @Paul Beusterien,非常感谢您对我的帮助,现在可以了。 吊舱使用:

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

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

【问题讨论】:

  • 复制/粘贴 podspec 和错误的内容,而不是屏幕截图。
  • @Larme 嗨,谢谢!我更新了我的问题。
  • 您可能需要将 libstdc++.6.0.9.tbd 复制/添加到项目中 (stackoverflow.com/questions/50694822/…)
  • @WildsonLee 解决方案是什么?现在解决同样的问题

标签: c++ ios cocoapods podspec


【解决方案1】:

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

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

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

在私有头文件中,您可以安全地包含 stdlib 头文件

【讨论】:

    【解决方案2】:

    known CocoaPods issue 无法对 C++ 标头进行 lint。

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

    【讨论】:

    • 非常感谢!但是我在xcode中运行我的项目有同样的错误,也许选项“-skip-import-validation”只是通过了验证的pod
    猜你喜欢
    • 2020-03-01
    • 1970-01-01
    • 2017-01-18
    • 2016-08-24
    • 2019-10-11
    • 2014-12-13
    • 2016-10-02
    • 2017-01-06
    • 2014-08-11
    相关资源
    最近更新 更多