在设置中启用了 Xcode 模块,但仍然无法使用 @import

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32555710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:48:42  来源:igfitidea点击:

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

objective-cxcode

提问by Taylor

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

在设置中,“启用模块”设置为是:

Enable Modules

启用模块

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

但我仍然收到错误消息:“禁用模块时使用‘@import’。”

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?

是否存在 Xcode 回退到包含而不是使用模块的情况?

回答by MaxGabriel

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

模块不可用的一个地方是 Objective-C++ 代码(.mm文件扩展名),这对于在 C/C++ 和 Objective-C 之间进行通信的项目来说是值得注意的。

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

如果您@import在 Objective-C++ 文件中使用该语法,您会收到与您报告的相同的错误(“禁用模块时使用‘@import’”)。

The Clang docssay:

锵文档说:

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

目前,没有用于导入声明的 C 或 C++ 语法。Clang 将跟踪 C++ 委员会中的模块提案。

which I take to be referring to this unavailability.

我认为这是指这种不可用性。