Does GeometryReader not work any more in iOS Swift Playgrounds for iPad (ver 3.4) ?

Does GeometryReader not work any more in iOS Swift Playgrounds for iPad (ver 3.4) ? This code runs fine on MBP in Xcode ... fails on line 7 with Abort() Called on iPad from a start up Blank 5.3 playground.


Code Block swift
import PlaygroundSupport
import SwiftUI
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
Color.blue
.frame(height: geometry.size.height * 0.5)
}
}
}
PlaygroundPage.current.setLiveView( ContentView() )


I'll see if I can identify specific places where iOS Swift Playgrounds for iPad ver 3.4 has other issues.

Replies

I think there is an issue currently where Playgrounds 3.4 GeometryReader isn't registering the screen size for the live view. I added the the frame modifier to the GeometryReader view and this allows it to run in Playgrounds 3.4 and not run into the Abort() issue. I tried to add the frame modifier to ContentView(), but it resulted in the Abort() function being called. Unsure if there is a place to see the logs for Playgrounds to see what causes Abort() to be called.

Code Block Swift
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
Color.blue.frame(height: geometry.size.height * 0.5)
}.frame(width:500, height: 500)
}

@Tylor,

Thanks for taking a look at this. I do want to confirm that I used GeometryReader extensively in the previous version of Swift Playgrounds for iPad - dozens of times in a card game where I computed best possible grid layout for cards as they were out of play in a solitaire game. The grid of cards dynamically changed for a best possible fit for aesthetics ... and even changed between horizontal, and vertical, or full screen and 1/2 screen for iPad. I had no issues at all with GeometryReader in previous version - it was very reliable.


Okay ... More information ... all the programs, that fail when running from iPad Pro, work fine when running from this same app on Mac. Same code, as all my programs are stored in iCloud !  (I did not even know you could get Swift Playgrounds on Mac - I thought you spun up a playground from out of Xcode solely.)

This fact alone negates me having to post examples of what fails, for others to try to spot any errors. If the same code runs fine from MBP, from this app ... but fails when run from this app on iPad ... then we definitely have an implementation issue on iPad for this app. 

The question is ... where is the best place to communicate this with Apple ? Does Apple monitor these post and get back with the developers ? If I had an issue with Xcode, or with an app, I could use my Developers account to create a ticket (I guess, I am new to the Developers account). But with this app ... not sure how to create a ticket exactly. 
@richiwalt,

Most of the current issues can be fixed with adding the frame modifier just inside the body view which fixes GeometryReader and ForEach. It is a temporary fix to get the program running in the app again. In the next update to Playgrounds (or potentially a mini update) will see this fixed (hopefully).

I do not know if Apple engineers monitor this form. Yes, there is a place where you can submit feedback to Apple. On all the latest versions of MacOS, iOS, and iPadOS, there is the Feedback app (Feedback Assistant on MacOS). Here you can submit errors, bugs, or feedback to Apple. I would fully suggestion entering feedback to send to Apple, so they can get a better understanding of what is occurring.
I’m beginning to suspect that the team/process which packaged the 3.4 release did not update the linked SwiftUI library that was used to compile and test Playgrounds. (This is just a hunch since I cannot inspect what’s in the app’s package on the iPad — I don’t have a Mac to do this kind of inspection.) The errors are all related to SwiftUI, and seem to mostly relate to layout. Some of my playgrounds are drawn half offscreen before they crash.

However, it’s not just limited to UI elements. In one very complicated playground, it crashes because the environment object hasn’t been instantiated before the views are orchestrated. This is serious, since the contract is that the environment must be set up *before* views are instantiated.

I also suspect that testing wasn’t done on an actual iPad since you say that they work on the Mac. My guess is that tests were run on Macs with Playgrounds running as a Catalyst app. Just a hunch. But who would have certified the tests had they seen what happens on an actual iPad?

For the moment, until an update to fix this, I’m dead in the water.

The fix using frame modifier doesn't work for me...
It's not working for me either.
I found that when you toggle off enable results the playground runs successfully without the need to provide a frame modifier.

macOS 11.2.1 - Playgrounds 3.4