Playground Support

RSS for tag

Share playground data, manage live views, and control the execution of a playground in Swift Playgrounds using Playground Support.

Playground Support Documentation

Posts under Playground Support tag

17 Posts
Sort by:
Post not yet marked as solved
0 Replies
261 Views
i have a simple code running on Xcode 15.2 and is showing blank in the liveView I am expecting to see Hello button in default blue , which navigates me to empty screen when tapped can someone helpe me why preview is not rendering properly? thank you so much
Posted Last updated
.
Post not yet marked as solved
1 Replies
258 Views
I am using Swift Playground to teach "coding" to my nephew. One of the strict requirements I am trying to explain him is: when you are required to solve a problem, you need to use only the instructions/harward/etc you have available. In the first episode of "Get started with code" -> "Commands" -> "Issuing commands", you are presented with two commands moveForward() and collectGem(). In the second episode "Toggle a Switch" you are introduced to a new command "toggleSwitch()". Up to this point, the learner was introduced to three commands: moveForward(), collectGem(), toggleSwitch(). However, in order to solve the puzzle in the second episode, you need also to use another command: turnLeft(), that has not been referenced. It is clear that looking for unknown commands is part of learning to code, but this occurs too early in the playground. Please consider also that some non-English young learners have no idea on how to write "turn left", so they cannot even type the first letters and hope in the auto-completion of the commands. This has not been well thought by the designers of the playground.
Posted Last updated
.
Post not yet marked as solved
7 Replies
561 Views
Hey folks! I remember some weeks/months ago to get some lessons with updated Swift 5.9, I'm just not sure if this happened while I was using Swift Playgrounds beta from TestFlight. Anyways, I went back to study using Swift Playgrounds and all the lessons are using Swift 5.8 here. I don't know what happened or how can I have the lessons updated again. Anyone else noticed this issue? Any tip on how to solve it?
Posted
by xDhii.
Last updated
.
Post not yet marked as solved
4 Replies
2.3k Views
Have downloaded playgrounds 4.3 to my iPad Air running ipados 16.5. Trying to use playground “Get started with Apps” but receiving message “Unsupported file format Get Started with Apps.swiftpm cannot be opened in Swift Playgrounds”. I do not have Mac or windows PC so am stuck! Help ??
Posted Last updated
.
Post not yet marked as solved
1 Replies
431 Views
Hi, I'm just starting out and I'm trying to learn Swift with various tools including the Playground and I'm doing the "continue with the apps" exercises. I'm stuck at the point where I need to add the Colorpicker to change the color. The code seems right but the app won't let me move forward. struct CreatureDetail: View { /#-code-walkthrough(creatureDetail.intro)/ /#-code-walkthrough(creatureDetail.creatureConstant)/ let creature : Creature /#-code-walkthrough(creatureDetail.creatureConstant)/ //#-learning-code-snippet(addStateVarIsScaled) /*#-code-walkthrough(creatureDetail.stateVars)*/ @State var color = Color.white @State var shadowRadius : CGFloat = 0.5 @State var angle = Angle(degrees: 0) /*#-code-walkthrough(creatureDetail.stateVars)*/ var body: some View { VStack { Text(creature.emoji) .resizableFont() .colorMultiply(color) .shadow(color: color, radius: shadowRadius * 40) .rotation3DEffect(angle, axis: (x: 0.0, y: 1.0, z: 0.0)) ColorPicker("Choose a Color", selection: $color) .padding(.horizontal) } } }
Posted
by Piteke.
Last updated
.
Post not yet marked as solved
2 Replies
583 Views
I've seen a few post about this issue Apple continuously has had for years now. I have tried all the solutions that I have seen, but the error still persists. I have zero to little knowledge on Swift/Xcode, coding in general, and I have no idea where to look for these issues. I believe I am using Xcode 15 on macOS Sonoma V14.0. This the error I keep receiving: error: error while processing module import: error: /var/folders/3v/dmv573gn64b364sgv041tw7c0000gn/T/playground24-a1e85e..swift:3:25: error: expected ',' in #sourceLocation directive #sourceLocation(file: ""Hello, World!".playground", line: 1) I just want to learn but this error is really discouraging lol help!
Posted
by APTn.
Last updated
.
Post not yet marked as solved
0 Replies
779 Views
Creating an Observable class in an Xcode playground seems to cause an error. This stops me from being able to run the playground. As a demo, try creating a playground page and add: import Foundation import Observation // Doesn't seem to make a difference whether it's added or not. @Observable public class NewViewModel: Observable { var value: Int = 1 func increment() { value += 1 } } Tapping the run button logs the following error (and then it builds successfully, buy fails silently): error: Untitled Page.xcplaygroundpage:7:9: error: expansion of macro 'ObservationTracked()' did not produce a non-observing accessor var value: Int = 1 ^ Putting the cursor on @Observable and then selecting Editor > Expand Macro shows that value has been annotated with @ObservationTracked and I if I re-run the playground I can even see the @ObservationTracked generated code. Macros: import Foundation import Observation // Doesn't seem to make a difference whether it's added or not. @Observable public class NewViewModel: Observable { @ObservationTracked // original-source-range: /Users/gabriel.banfalvi/work/forums_observation/ObservationFramework.playground/Pages/Untitled Page.xcplaygroundpage:7:5-7:5 var value: Int = 1 { @storageRestrictions(initializes: _value) init(initialValue) { _value = initialValue } get { access(keyPath: \.value) return _value } set { withMutation(keyPath: \.value) { _value = newValue } } } // original-source-range: /Users/gabriel.banfalvi/work/forums_observation/ObservationFramework.playground/Pages/Untitled Page.xcplaygroundpage:7:20-7:23 func increment() { value += 1 } @ObservationIgnored private let _$observationRegistrar = Observation.ObservationRegistrar() internal nonisolated func access<Member>( keyPath: KeyPath<NewViewModel, Member> ) { _$observationRegistrar.access(self, keyPath: keyPath) } internal nonisolated func withMutation<Member, MutationResult>( keyPath: KeyPath<NewViewModel, Member>, _ mutation: () throws -> MutationResult ) rethrows -> MutationResult { try _$observationRegistrar.withMutation(of: self, keyPath: keyPath, mutation) } @ObservationIgnored private var _value: Int = 1 // original-source-range: /Users/gabriel.banfalvi/work/forums_observation/ObservationFramework.playground/Pages/Untitled Page.xcplaygroundpage:12:1-12:1 } I can't seem to be able to expand the @ObservationIgnored macros, which may or may not be related to the issue. I can't expand them in a regular Xcode app, but it doesn't lead to any problems there. Im running an iOS playground. I get this in Xcodes 15 beta 6 and 5. I get a different error in earlier versions.
Posted Last updated
.
Post not yet marked as solved
0 Replies
524 Views
When I import a package in Swift Playgrounds on my iPad, I receive the following error: This package interactions with libgit2, and it don’t have any release in the origin repository, so I find a existing fork which have release. Playgrounds version: 4.3.1(1727.53) Is it means that I install a software that supports unzip on iPad?
Posted
by Heyya.
Last updated
.
Post not yet marked as solved
1 Replies
688 Views
Is there a Form where I, a noobie, can ask really basic questions about this learning environment? As an example, I discovered the semi-colon in doing a task in the early part of "learn to Code" but I have not found any documentation for it. I am sure I will have other questions but right now I am just looking for a place to ask them. Thank you in advance.
Posted
by Davaruna.
Last updated
.
Post not yet marked as solved
1 Replies
798 Views
My while loop continues execution after reaching gemsCollected = 3 if I use OR logical operator (||) and stops execution if I use AND logical operator (&&). IMHO it should be the other way around, right? var gemsCollected = 0 var switchesToggled = 0 while gemsCollected < 3 || switchesToggled < 4 { moveForward() if gemsCollected < 3 && isOnGem { collectGem() gemsCollected = gemsCollected + 1 } else if switchesToggled < 4 && isOnClosedSwitch { toggleSwitch() switchesToggled = switchesToggled + 1 } else if isBlocked && !isBlockedRight { turnRight() } else if isBlocked && !isBlockedLeft { turnLeft() } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
693 Views
I randomly have errors with any playground. Is this just a random timeout with iCloud? I checked perms and my account has read & write to the playground and the folder it's (Playgrounds in iCloud Drive). I've never opened a playground and found anything missing, so it must be saving. I was not on VPN with this most recent error (though sometimes I am). I'm on an M1 Pro Mac.
Posted
by abrinael.
Last updated
.