简体   繁体   English

Swift UI Xcode 11 beta 5-构建时出错

[英]Swift UI Xcode 11 beta 5 - Error when building

I'm having this error 'The compiler is unable to type-check this expression in reasonable time; 我收到此错误消息:“编译器无法在合理的时间内对这个表达式进行类型检查; try breaking up the expression into distinct sub-expressions' every-time I try to build my app and every-time I build the error is in a different view and in different parts of the code. 每次尝试构建我的应用程序时,都尝试将表达式分解为不同的子表达式,并且每次构建错误时,都会在不同的视图中以及代码的不同部分。 Normally it shows where I have a ForEach or a .sheet Presentation but there are views that have them and they don't give an error. 通常,它显示了我有ForEach或.sheet演示文稿的位置,但是有包含它们的视图,并且它们不会给出错误。 This only happened when I updated to xCode 11 beta 5, is anyone with the same error? 这仅在我更新到xCode 11 beta 5时才发生,有人有同样的错误吗?

Already tried to replace the ForEach and .sheet on the views but there are views that have ForEach and they don't give an error and they exactly the same. 已经尝试替换视图上的ForEach和.sheet,但是有些视图具有ForEach,并且它们没有给出错误且它们完全相同。

The expected result is not having that error when compiling, but for some reason it always shows: 'The compiler is unable to type-check this expression in reasonable time; 预期的结果在编译时不会出现该错误,但是由于某种原因,它始终显示:'编译器无法在合理的时间中对该表达式进行类型检查; try breaking up the expression into distinct sub-expressions' 尝试将表达式分解为不同的子表达式

I had that problem, and it is documented in the last release notes (beta 5): 我遇到了这个问题,最近的发行说明(测试版5)中记录了该问题:

Using a ForEach view with a complex expression in its closure can may result in compiler errors. 如果在封闭视图中使用复杂表达式的ForEach视图,可能会导致编译器错误。 Workaround: Extract those expressions into their own View types. 解决方法:将这些表达式提取到自己的视图类型中。 (53325810) (53325810)

When you get the The compiler is unable to type-check this expression in reasonable time; 当您得到时, 编译器将无法在合理的时间中对该表达式进行类型检查;否则,编译器将无法对其进行类型检查。 try breaking up the expression into distinct sub-expressions error, ignore all other errors, as they cannot be trusted. 尝试将表达式分解为不同的子表达式错误,忽略所有其他错误,因为它们是不可信任的。 First you need to address the "reasonable time" problem. 首先,您需要解决“合理的时间”问题。

You need to encapsulate the contents of the ForEach, and it will most likely go away. 您需要封装ForEach的内容,它很可能会消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM