Mahbubur Rashid
Mahbubur Rashid

Reputation: 19

Form C header file "'vector' file not found" error happening into swift

I am trying to integrate an Objective-C SDK into my swift file. But when I want to add some of the files from the SDK into my Bridging Header I am getting this error 'vector' file not found

I am also getting string file not found if I want to add other file to the swift header.

I discover these are the C header file. SDK provider gave some hint like create a .mm file, but how they don't know.

I have tried adding all the C or C++ supporting files like libstdc++.6.tbd,libstdc++.6.0.9.tbd, libstdc++.6.0.9.dylib, libstdc++.6.dylib, libstdc++.dylib but nothings changed.

Here is the error https://pasteboard.co/InhuW5K.png

And here is the Bridging Header file integration

#ifndef IOT_Demo_Bridging_Header_h
#define IOT_Demo_Bridging_Header_h //#ifndef ObjectiveCHeader_h //#define ObjectiveCHeader_h

#import <LCOpenSDKDynamic/LCOpenSDK_Api.h> //#import "../Depend/LCOpenSDK/LCOpenSDK_Api.h"
#import <LCOpenSDKDynamic/LCOpenSDK_AudioTalk.h>
#import <LCOpenSDKDynamic/LCOpenSDK_PlayWindow.h>
#import <LCOpenSDKDynamic/LCOpenSDK_EventListener.h>
#import <LCOpenSDKDynamic/LCOpenSDK_TalkerListener.h>
#import <LCOpenSDKDynamic/DeviceList.h>
#endif

I am stuck with is this error for some days. Please help. Thanks in advance.

Upvotes: 0

Views: 1486

Answers (1)

Anatoli P
Anatoli P

Reputation: 4891

It sounds like you are running into problems trying to use C++ code in Swift. See, for example, this answer: Interacting with C++ classes from Swift. vector and string are standard C++ library headers.

Also, doing searches like use c++ in swift, call c++ from swift, etc. in Google and StackOverflow should provide enough examples of how to handle this.

Briefly, one approach is to write an Objective-C++ wrapper. Implementation files, with the .mm extension, will be a mixture of Objective-C and C++ code, i.e. C++ API can be invoked by code in those files. However, the functions that are to be made visible to Swift via the bridging header should not use C++ types as parameters or return values.

Upvotes: 0

Related Questions