1
2

More than 1 year has passed since last update.

【SwiftUI】The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressionsを解決

Last updated at Posted at 2022-06-24

はじめに

私はSwiftUIに慣れるまでこのエラーを出しまくりました。
しかし、よくエラーの意味がわかりませんでした笑

最近になって解決方法がわかったので記録しておきます。

エラー文

Xni95.png

The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

「コンパイラは、この式を合理的な時間で型チェックすることができません。この式を個別の部分式に分割してみてください。」ということらしいです

原因

「Viewの中にエラーがあるがコードが多すぎでどこがエラーかわからない」

おそらくこんな感じではないかと思っています。

解決方法

Viewの中の要素を一つずつコメントアウトして原因箇所を探す

コードが少なくなるときちんとエラーが表示されるようになります。

おわり

おそらく、このエラーが出る方はクソでかViewを作っちゃっているので、
Viewは小さく分割して作るのがいいと思います。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2