6

Yesterday I upgraded XCode and my project to iOS 13.4 and I started to see a lot of failures in around views that use GeometryReaders.

The error does not reveal anything besides "precondition failure: invalid input index"

Andrei Matei
  • 1,049
  • 2
  • 10
  • 23

2 Answers2

4

I had the exact same issue after upgrading to 13.4.1.

I installed a simulator with 13.3.3 and it didn't have the issue.

What ended up causing the issue was having a GeometryReader as an inner view of a NavigationView. Making the GeometryReader the top-most view fixed it for me.

MarkosDarkin
  • 315
  • 3
  • 20
  • 1
    This answer might be a nice temporary fix to get going again, but if this is indeed the issue this seems like a critical bug. Not being able to (consistently) use GeometryReader inside a NavigationView is a gamebreaker! – JillevdW Sep 07 '20 at 13:53
0

After debugging and starting to lose my mind, I found that each view that had a GeometryReader also was using onReceive with a call to a function that had Combine code.

Basically I was calling .collect() on the Publisher and sink-ing the result to a variable.

After I removed the Combine code and started to use old fashioned array operations, all started working again.

Andrei Matei
  • 1,049
  • 2
  • 10
  • 23
  • 1
    hi Andrei, the latest update has also broken my Watch app that uses SwiftUI. I use GeometryReader to read the size of the screen so I can draw a frame in a size relative to the screen size. So I using geometry.size.width and geometry.size.height, I get precondition failure: invalid input index: 2. I seem to think it relates to the height, but I'm not sure what is wrong. – alamodey Mar 29 '20 at 05:28
  • 1
    Do you use Combine in any way? I also was suspecting geometry.size.height but after removing all the Combine code, it started working again – Andrei Matei Mar 29 '20 at 14:58
  • I'm seeing the exact same problem as @alamodey. Has anyone managed to reproduce this in a sample project? This doesn't seem like expected behaviour at all – Joey Slomowitz May 08 '20 at 08:45
  • I am seeing the same issue. Any solution ? – Badrinath May 09 '20 at 00:07
  • @alamodey my crash is only appearing in simulator. It runs fine on device, except (oddly) when running the app using the VoiceOver accessibility feature – Joey Slomowitz May 11 '20 at 03:11
  • @JoeySlomowitz you are right, the app doesn't crash on device but it does in simulator. Carry on! – alamodey May 16 '20 at 06:40