Posts

Post not yet marked as solved
8 Replies
3.1k Views
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. 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.
Posted
by richiwalt.
Last updated
.
Post not yet marked as solved
5 Replies
1.9k Views
The following code fails to run from a fresh Blank Swift 5.3 playground in the Swift Playgrounds app for iPad. I have cut and cut the original code down to this ... which I think is pretty simple. I have also tested this for any syntax errors on MBP Xcode (where it runs with no problem). However on the iPad, after the new Playgrounds app update, it fails on line 26 with: Abort() called import PlaygroundSupport import SwiftUI struct Fruit: Identifiable { 		let id = UUID() 		let name: String 		let emoji: String 		 		static var list = [ 				Fruit(name: "Apple", emoji: "🍎"), 				Fruit(name: "Bannanna", emoji: "🍌"), 				Fruit(name: "Cherry", emoji: "🍒"), 				] } struct ContentView: View { 		 		let fruitList = Fruit.list 		let sortAscending = false 		 		var body: some View { 				 				List { 						ForEach( fruitList ) { fruit in 								HStack { 										Text("\(fruit.emoji)") 										Text("\(fruit.name)") 								} 								.font(.title) 						} 				} 		} } PlaygroundPage.current.setLiveView( ContentView() ) This and many other apps have all broken after the iOS Swift Playgrounds app updated to version 3.4.
Posted
by richiwalt.
Last updated
.
Post not yet marked as solved
1 Replies
692 Views
This code doesn't seem to work correctly. It should spin a system image using a very simple view modifier. Am I doing anything wrong in the code ? import PlaygroundSupport import SwiftUI struct ContentView: View {     var body: some View {         Image(systemName: "timer")             .spinning()     } } struct Spinning: ViewModifier {     @State var isVisible: Bool = false     func body(content: Content) -> some View {         content             .rotationEffect( Angle(degrees:  isVisible ? 360 : 0 ))             .animation(Animation.linear(duration: 1).repeatForever(autoreverses: false))             .onAppear { isVisible = true }     } } extension View {     func spinning() -> some View {         self.modifier(Spinning())     } } PlaygroundPage.current.setLiveView( ContentView() ) This app used to be Amazing ... what happened on the last update ?
Posted
by richiwalt.
Last updated
.
Post marked as solved
5 Replies
1.5k Views
The following "Hello World" app fails to run with Error: GeometryProxy cannot be constructed because it has no accessible initializers. Likewise about 50 to 60 SwiftUI perfectly good programs worked flawlessly before I updated the app about 20 minutes ago. Now, none of them work. Where is the proper place to report a major of releasing this version of the app ? import SwiftUI import PlaygroundSupport struct ContentView: View {     var body: some View {         GeometryProxy { geometry in              Text("Hello World")                 .frame(width: geometry.size.width * 0.9 )         }     } } PlaygroundPage.current.setLiveView( ContentView() )
Posted
by richiwalt.
Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
Thanks for the video in wwdc20, I’m looking for anything that would help enable app programs to run correctly now, that were working in version 3.2 of Swift Playgrounds app running on iPad Pro 12.4” 4th Gen before the update, but have failed with many generic errors for update version 3.4 version of this app released a few days ago. I generally started with a Blank Playground template, but after watching the video, I am wondering if starting with an XCode template might help with these Abort() Called errors. I do not see any errors when running from MBP ... but if I am running on MBP, I unusually use real XCode IDE. BTW ... I did not know about dragging the final brace downward to exclude code in newly added functions, pretty cool! thanks for any help
Posted
by richiwalt.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
In the previous version of the Swift Playgrounds for iPad app, I was able to rely on using data through JSON files with companion struct. This code is cut way back to demonstrate that JSON data is not processed. It never fails, but then it also never does anything either. This code was also tested (for any syntax errors) on Xcode 12.2 on MBP running Catalina 10.15.7 where it ran flawlessly. Before the previous Swift Playgrounds update, it ran flawlessly on iPad as well. import PlaygroundSupport import SwiftUI struct MovieObject: Codable, Identifiable {     let id: Int     let thumbnail: String     let title: String     let description: String     let trailerLink: String     let catagory: String     let isFeaturedMovie: Bool } let movies = Bundle.main.decode([MovieObject].self, from: "movie_data.json") struct ContentView: View {     var body: some View {         ForEach(movies) { movie in              Text("\(movie.title)")         }     } } import UIKit extension Bundle {     func decode<T: Decodable>(_ type: T.Type, from file: String) -> T {         guard let url = self.url(forResource: file, withExtension: nil) else {             fatalError("Failed to locate \(file) in bundle.")         }                 guard let data = try? Data(contentsOf: url) else {             fatalError("Failed to load \(file) from bundle.")         }         let decoder = JSONDecoder()         guard let loaded = try? decoder.decode(T.self, from: data) else {             fatalError("Failed to decode \(file) from bundle.")         }         return loaded     } } PlaygroundPage.current.setLiveView( ContentView() ) A sample of the JSON file called "movie_data.json" that was imported to the Playground with the + button is seen here: [ { "id": 1, "thumbnail": "place some url here this forum doesn't allow links", "title": "Aquaman", "description": "Once home to the most ...", "trailerLink" : "place some url here this forum doesn't allow links", "catagory": "DC", "isFeaturedMovie": true }, { "id": 2, "thumbnail": "place some url here this forum doesn't allow links", "title": "The Avengers", "description": "S.H.I.E.L.D. leader Nick Fury is blah blah blah ", "trailerLink" : "place some url here this forum doesn't allow links", "catagory": "Featured", "isFeaturedMovie": false }, { "id": 3, "thumbnail": "place some url here this forum doesn't allow links", "title": "Avengers - Age Of Ultron", "description": "Tony Stark builds ... blah blah blah", "trailerLink" :"place some url here this forum doesn't allow links", "catagory": "Marvel", "isFeaturedMovie": false }, ] The full blown app (before I trimmed it down severally) had scrollable thumbnails of various movies in horizontal rows in a sidebar ... when one was tapped, a detailed view gave a description with a Play button that went to You Tube to play the trailer in the browser ... it ran flawlessly on iPad Swift Playgrounds app. I have probably placed enough post to demonstrate that I think the newest version of this app is pretty much busted. Looking forward to some major damage control in a future update to fix things back up.
Posted
by richiwalt.
Last updated
.
Post not yet marked as solved
5 Replies
2.6k Views
This code runs fine on MBP in Xcode. But in iOS Swift Playgrounds it fails on line 9 with: There was a problem encountered while running this playground. Check your code for mistakes on iPad from a start up Blank 5.3 playground. import PlaygroundSupport import SwiftUI struct ContentView: View {     var emojis = "🐿 🐝🦋🐌🐞🐜🐛🦒🐘🦛🦓🦏🐪"     var body: some View {         VStack {             ScrollView(.horizontal) {                 HStack {                     ForEach( emojis.map { String($0) }, id: \.self ) { emoji in                         Text(emoji).font(Font.system(size: 45))                     }                 }                 .padding(.horizontal)             }             Color.yellow             .edgesIgnoringSafeArea([.horizontal, .bottom])         }         .background(Color.white)     } } PlaygroundPage.current.setLiveView( ContentView() ) I have whittled this code down a lot from the Stanford SwiftUI 2020 course posted on YouTube. The whole EmojiArt app worked flawlessly as of lecture 7 in iOS Swift Playgrounds for iPad in version 3.2 a few days ago before the upgrade to version 3.4. Now, this, as well as many other apps have all broken after the iOS Swift Playgrounds app updated to version 3.4.
Posted
by richiwalt.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
I would like to use a ViewModifier, called Cardify, where the content conforms to Shape.  I use content twice within my ViewModifier ... once for those cards that require filled shapes (paths) with colors (either solid, or transparent) and a second time for shapes that require a simple outlined only to be used on the cards. That second use of content is where things fall apart, as the compiler complains about me trying to stroke() content. How can I tell the ViewModifier that content will also conform to Shape protocol, so that I can use: content.stroke() struct Cardify: ViewModifier {     let card: CardForView     func body(content: Content)  -> some View {         ZStack {             VStack {                 ForEach( 0..<card.pips ) { _ in                     ZStack {                         content.opacity(self.card.shading)                         content.stroke()                     }                                    .foregroundColor(self.card.color)                     .scaleEffect(self.card.isSelected ? 0.60 : 1.0 )                 }             }             .padding() // for shapes within RoundedRect             RoundedRectangle(cornerRadius: 10).stroke(lineWidth: card.isSelected ? 3.0 : 1.0).foregroundColor(.orange)             .scaleEffect(self.card.isSelected ? 0.60 : 1.0 )         }         .padding() // for Grid within GameBoard         .aspectRatio(2/3, contentMode: .fit)     } } extension View {     func cardify(card: CardForView) -> some View {         return self.modifier(Cardify(card: card))     } }
Posted
by richiwalt.
Last updated
.