aws/amazon-chime-sdk-ios

Compilation Errors when using Amazon SDK SPM with Objective-C++

arehman86 opened this issue · 3 comments

I have an Objective-C++ project which I am working on right now. Previously I have downloaded xcframeworks and used it manually but now I have to use SPM. So I removed xcframeworks from the project and used SPM with video. When compiling the code I am getting compilation errors. I am importing the header like this #import <AmazonChimeSDK/AmazonChimeSDK-Swift.h> but getting compilation errors in this header.

To Reproduce
Add Amazon chime sdk spm to the project and import the header AmazonChimeSDK/AmazonChimeSDK-Swift.h and try to compile. It will give compilation errors.

Note
I created the issue before which was closed without any further help as I have provided a test project in which I was facing the issue. Is there any way that your sdk is supported for Objective-C++?

Related issue which I created is #672

I am attaching a test project as well which includes AmazonChime SPM
amazon-chime-sample 2.zip

Hi @arehman86,

We don't support Swift and Objc-C++ interoperability, my suggestion is to create a interop layer in your project. I also tried manually import Chime SDK into your project, I got the same errors. If you think you are able to get the manual import approach work, please share me the sample project.

@georgezy-amzn
I fixed it by creating an umbrella header and include all the required headers in it and used where ever it was needed as Objective-C Modules are not enabled for my project and I don't want to enable it for some reason.

#import <AVFAudio/AVFAudio.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreFoundation/CoreFoundation.h>
#import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AmazonChimeSDKMedia/AmazonChimeSDKMedia.h>
#import <AmazonChimeSDK/AmazonChimeSDK-Swift.h>

Just a suggestion, if you want the SDK to be used for those projects which doesn't require Objective-C Modules to be enabled then you should add the following in AmazonChimeSDK-Swift.h or the end user needs to include it by themselves.

#if defined(OBJC)
#if __has_feature(objc_modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import AVFAudio;
@import AVFoundation;
@import AmazonChimeSDKMedia;
@import CoreFoundation;
@import CoreMedia;
@import CoreVideo;
@import Foundation;
@import ObjectiveC;
@import UIKit;
#else
#import <AVFAudio/AVFAudio.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreFoundation/CoreFoundation.h>
#import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AmazonChimeSDKMedia/AmazonChimeSDKMedia.h>
#endif
#endif

Thanks for sharing this! I'll mark this as feature request.