dimanche 26 juin 2016

Using C++ inside an iOS CocoaPod

I am building a private cocoapod for iOS, and am running into issues with some C++ code. The project builds fine in XCode, but when I attempt to run pod lib lint MyProjectName.podspec I get the following error:

- ERROR | xcodebuild: /path/to/aheader.h:2:10: error: 'string' file not found

The header has the following first line:

#include <string>

Searching for possible solutions, I added the following to podspec (based on CocoaPods: Linking with C++ symbols defined in libPods.a)

s.source_files = "MyProjectName/**/*.{swift,c,m,h,mm,cpp,plist}"
s.library = 'c++'
s.xcconfig = {
   'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11',
   'CLANG_CXX_LIBRARY' => 'libc++'
}

But it made no difference to the error. Another suggestion I saw was to "use a wrapper", but this piece of code (which is 3rd-party IP that I can not port to Objective C) is already using a wrapper.

How can I build the pod successfully by mixing both Objective C and C++ along with Swift? Any (non-null) pointers would be appreciated.

Aucun commentaire:

Enregistrer un commentaire