Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode modules enabled in settings, but still can't use @import

In settings, "Enable Modules" is set to Yes:

Enable Modules

And yet I still get the error: "Use of '@import' when modules are disabled."

Error

This is on a project I'm updating to use Modules, not a new project (works fine in a new project).

Are there conditions where Xcode falls back to includes instead of using modules?

like image 287
Taylor Avatar asked Sep 14 '15 00:09

Taylor


1 Answers

One place that modules aren't available is in Objective-C++ code (.mm file extension), which is notable for projects communicating between C/C++ and Objective-C.

If you use the @import syntax in an Objective-C++ file, you get the same error you reported ("Use of '@import' when modules are disabled").

The Clang docs say:

At present, there is no C or C++ syntax for import declarations. Clang will track the modules proposal in the C++ committee.

which I take to be referring to this unavailability.

like image 52
MaxGabriel Avatar answered Nov 17 '22 21:11

MaxGabriel