加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – 枚举的字符串插值产生“unknown()”字符串

发布时间:2020-12-14 04:36:24 所属栏目:百科 来源:网络整理
导读:简单的枚举和插值: enum Test { case test1 case test2 case test3}let a = Test.test1let b = "(a)" 从调试窗口我得到: a = (Test) test1b = (String) "unknown()" 问题是这发生在我的项目中,而不是在操场上. 在项目中: 在操场上: 在日志中我得到: SW
简单的枚举和插值:

enum Test {
    case test1
    case test2
    case test3
}

let a = Test.test1
let b = "(a)"

从调试窗口我得到:

a = (Test) test1
b = (String) "unknown()"

问题是这发生在我的项目中,而不是在操场上.

在项目中:

in project

在操场上:

in playground

在日志中我得到:

SWIFT RUNTIME BUG:无法找到类型’ProjectName的字段元数据.(0x10672213c处的未知上下文).Test’

有什么问题?项目目标iOS是9.我确实将项目转换为swift 4.2.我在XCode 10测试版上遇到过这个问题,并希望它能得到修复,但我想这不是IDE或Swift问题.

解决方法

您需要确保启用“反射元数据级别”构建设置:

enter image description here

可以在here找到此构建设置的说明:

Reflection Metadata Level (SWIFT_REFLECTION_METADATA_LEVEL)

This setting controls the level of reflection metadata the Swift compiler emits.

  • All: Type information about stored properties of Swift structs and classes,Swift enum cases,and their names,are emitted into the binary for reflection and analysis in the Memory Graph Debugger.
  • Without Names: Only type information about stored properties and cases are emitted into the binary,with their names omitted. -disable-reflection-names
  • None: No reflection metadata is emitted into the binary. Accuracy of detecting memory issues involving Swift types in the Memory Graph Debugger will be degraded and reflection in Swift code may not be able to discover children of types,such as properties and enum cases. -disable-reflection-metadata

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读