Wildson Lee
Wildson Lee

Reputation: 41

CocoaPod - Podspec linting errors when using C++ in header files

I have an issue when linting headers file include C++.

pod lib lint MyLibrary.podspec

Here is my header file declare:

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

I get the following error PathToMyHeader:31:10: fatal error: 'memory' file not found

I think 'string', 'vector', 'stdexpept' will be the same errors

Here is my 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'
  }

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

Update 09/13/2018 @Paul Beusterien, thank you so much for help me, it works now. pod using:

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

but after I call pod install for my project in workplace, its seem just passed the pod, but show the same errors when I run my project Error

Upvotes: 4

Views: 2159

Answers (2)

CarloMinds
CarloMinds

Reputation: 1991

Add your c++ header files to the private header group.

With podspec you can add like this

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

Inside the private header files, you can safely include stdlib headers

Upvotes: 1

Paul Beusterien
Paul Beusterien

Reputation: 29582

It is a known CocoaPods issue to fail to lint C++ headers.

The workaround is the option --skip-import-validation

Upvotes: 2

Related Questions