xcode Objective C 中项目的“Swift 语言版本”(SWIFT_VERSION)构建设置错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47743271/
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 10:28:19  来源:igfitidea点击:

The “Swift Language Version” (SWIFT_VERSION) build setting error with project in Objective C

objective-cxcode

提问by meltonCG

So i just went to build my app after adding in core data to update my app to store and fetch some information and i got this error. (I am using XCode 9.2)

所以我只是在添加核心数据以更新我的应用程序以存储和获取一些信息之后去构建我的应用程序,但我收到了这个错误。(我使用的是 XCode 9.2)

The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

对于使用 Swift 的目标,“Swift 语言版本”(SWIFT_VERSION) 构建设置必须设置为支持的值。可以在构建设置编辑器中设置此设置。

Now whats confusing me is this in an Objective C app and surely the swift version shouldn't matter. I have browsed some threads on here stating that i need to update build setting to Swift 3.0 or to set values to Yes then back to No, however i have none of these fields when i search for Swift in the search bar.

现在让我感到困惑的是,这是在一个 Objective C 应用程序中,当然 swift 版本应该无关紧要。我在这里浏览了一些线程,指出我需要将构建设置更新为 Swift 3.0 或将值设置为是然后返回到否,但是当我在搜索栏中搜索 Swift 时,我没有这些字段。

buildSettings

构建设置

Is this just a bizarre bug or have i mistakenly added some swift code?

这只是一个奇怪的错误还是我错误地添加了一些快速代码?

Any ideas would help, thanks.

任何想法都会有所帮助,谢谢。

采纳答案by meltonCG

For Objective C Projects created using Xcode 8 and now opening in Xcode 9, it is showing the same error as mentioned in the question.

对于使用 Xcode 8 创建并现在在 Xcode 9 中打开的 Objective C 项目,它显示了与问题中提到的相同的错误。

To fix that, Press the + button in Build Settings and select Add User-Defined Setting.

要解决此问题,请按 Build Settings 中的 + 按钮,然后选择 Add User-Defined Setting。

Then in the new row created add SWIFT_VERSION as key and 3.2 as value like below.

然后在创建的新行中添加 SWIFT_VERSION 作为键和 3.2 作为值,如下所示。

It will fix the error for objective c projects.

它将修复目标 c 项目的错误。

回答by cmlloyd

I experienced this exact same issue after adding Core Data to an Objective-C framework I was working on.

在将 Core Data 添加到我正在开发的 Objective-C 框架后,我遇到了完全相同的问题。

I discovered that the reason I was getting the "Swift Language Version" warning was that the Code Generation language in the .xcdatamodel defaulted to Swift. Once I changed this back to Objective-C, the warning went away.

我发现我收到“Swift Language Version”警告的原因是 .xcdatamodel 中的代码生成语言默认为 Swift。一旦我把它改回 Objective-C,警告就消失了。

You can find this property in the File Inspector when you have the .xcdatamodel selected in the Project Navigator.

当您在 Project Navigator 中选择了 .xcdatamodel 时,您可以在 File Inspector 中找到此属性。

enter image description here

在此处输入图片说明