Error Use of '@import' when modules are disabled

Asked 1 years ago, Updated 1 years ago, 81 views

Add GoogleMobileAds framework to your project to deploy AdMob and add it to ViewController

@importGoogleMobileAds;

The error Use of '@import' when modules are disabled appears.

When I looked it up, it said that the error would disappear if Enable Modules (Cand C-Objective-C) were changed from NO to YES, so I tried it, but the error did not disappear.

What other possible causes are there?I would appreciate it if you could give me some advice.

objective-c admob

2022-09-30 11:21

2 Answers

As mentioned in the comment, the current Objective-C++ does not seem to support importing modules in @import.

You should find the appropriate .h file in the framework and import it with the old #import.According to this article,

#import<GoogleMobileAds/GoogleMobileAds.h>

It is written in so that you can import it.Try it.


2022-09-30 11:21

If it's Objctive-C,
Could it be @import<GoogleMobileAds> or @import "GoogleMobileAds"?I'm sorry if it was a mistake when posting.

Otherwise, select a project in the File Inspector on the left, click Build Phases in the build settings in the main view, and check if Link Binary With Libraries contains the appropriate framework.


2022-09-30 11:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.