Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx-modules #40

Closed
lucasoliveiraw00 opened this issue Oct 10, 2022 · 6 comments

Comments

@lucasoliveiraw00
Copy link

lucasoliveiraw00 commented Oct 10, 2022

Hello, I have an error when performing @import MobileMessaging; import, could you help me with this problem?

AppDelegate.mm: Use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx-modules

When adding the indicated flags, errors occur in other libraries when compiling.

  • MobileMessaging SDK version: 9.2.16
  • Xcode version: 14.0.1
  • Your application language: Objective-C++
  • Cocoapods version: 1.11.3

Originally posted by @lucasoliveiraw00 in #6 (comment)

@riskpp
Copy link
Contributor

riskpp commented Oct 11, 2022

Hi @lucasoliveiraw00 which errors occur on other libraries with -fcxx-modules option?
I'm not sure that we could help here much, the other solution is to try to make your own wrapper for the MobileMessaging module and use interfaces from it's header file, but it looks not very easy.

@riskpp
Copy link
Contributor

riskpp commented Oct 11, 2022

About the wrapper, this is just a simple example:

MobileMessagingCustomWrapper.h

#import <Foundation/Foundation.h>

@interface MobileMessagingCustomWrapper : NSObject

+ (void)startMobileMessagingWithApplicationCode:(NSString * _Nonnull)code;

@end

MobileMessagingCustomWrapper.m

#import "MobileMessagingCustomWrapper.h"

@import MobileMessaging;

@implementation MobileMessagingCustomWrapper

+ (void)startMobileMessagingWithApplicationCode:(NSString * _Nonnull)code {
    MMUserNotificationType *userNotificationType = [[MMUserNotificationType alloc] initWithOptions:@[MMUserNotificationType.alert, MMUserNotificationType.sound]];
    [MobileMessaging withApplicationCode: code notificationType: userNotificationType];
}

@end

AppDelegate.mm

#import "MobileMessagingCustomWrapper.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    [MobileMessagingCustomWrapper startMobileMessagingWithApplicationCode:@"Your app code"];

  return YES;
}
@end

@lucasoliveiraw00
Copy link
Author

lucasoliveiraw00 commented Oct 11, 2022

Hi @lucasoliveiraw00 which errors occur on other libraries with -fcxx-modules option? I'm not sure that we could help here much, the other solution is to try to make your own wrapper for the MobileMessaging module and use interfaces from it's header file, but it looks not very easy.

The following errors occur:
Captura de Tela 2022-10-11 às 11 24 13

@riskpp could you tell me which option would it be to add the fcxx-modules flag?, so I can check if it's in the correct location.

@riskpp
Copy link
Contributor

riskpp commented Oct 11, 2022

This is the screenshot which I did from the Example app
Screenshot 2022-10-11 at 18 08 35

@lucasoliveiraw00
Copy link
Author

About the wrapper, this is just a simple example:

MobileMessagingCustomWrapper.h

#import <Foundation/Foundation.h>

@interface MobileMessagingCustomWrapper : NSObject

+ (void)startMobileMessagingWithApplicationCode:(NSString * _Nonnull)code;

@end

MobileMessagingCustomWrapper.m

#import "MobileMessagingCustomWrapper.h"

@import MobileMessaging;

@implementation MobileMessagingCustomWrapper

+ (void)startMobileMessagingWithApplicationCode:(NSString * _Nonnull)code {
    MMUserNotificationType *userNotificationType = [[MMUserNotificationType alloc] initWithOptions:@[MMUserNotificationType.alert, MMUserNotificationType.sound]];
    [MobileMessaging withApplicationCode: code notificationType: userNotificationType];
}

@end

AppDelegate.mm

#import "MobileMessagingCustomWrapper.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    [MobileMessagingCustomWrapper startMobileMessagingWithApplicationCode:@"Your app code"];

  return YES;
}
@end

@riskpp, thank you very much, this solution worked!

@riskpp
Copy link
Contributor

riskpp commented Oct 25, 2022

You are welcome, I'll close the issue then.

@riskpp riskpp closed this as completed Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants