aws / amazon-chime-sdk-ios

An iOS client library for integrating multi-party communications powered by the Amazon Chime service.
https://aws.amazon.com/chime/chime-sdk/
Apache License 2.0
139 stars 64 forks source link

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

Closed arehman86 closed 1 month ago

arehman86 commented 1 month ago

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 https://github.com/aws/amazon-chime-sdk-ios/issues/672

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

georgezy-amzn commented 1 month ago

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.

arehman86 commented 1 month ago

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

georgezy-amzn commented 1 month ago

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