Taylor
Taylor

Reputation: 6430

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?

Upvotes: 11

Views: 6763

Answers (1)

MaxGabriel
MaxGabriel

Reputation: 7705

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.

Upvotes: 19

Related Questions