Hello All,
I am currently working through ”Keep going with Apps” in Swift Playground. The section in the tutorial “Add a DancingCreature view” will not complete. I have tried to type it is as written in the tutorial and even used the copy and paste button provided. I have restarted the app and my IPad with no success. I have attached a screen shot of the tutorial prompt.
Here is the code block:
import SwiftUI
import Guide
struct DancingCreatures: View {
//#-learning-code-snippet(varDeclaration)
@EnvironmentObject var data : CreatureZoo
var body: some View {
SPCAssessableGroup(view: self) {
VStack {
ZStack {
/*#-code-walkthrough(dance.forEach)*/
ForEach(data.creatures) { creature in
/*#-code-walkthrough(dance.forEach)*/
/*#-code-walkthrough(dance.textView)*/
Text(creature.emoji)
.resizableFont()
.offset(creature.offset)
.rotationEffect(creature.rotation)
/*#-code-walkthrough(dance.textView)*/
}
}
ZStack {
/*#-code-walkthrough(dance.forEach)*/
ForEach(data.creatures) { creature in
/*#-code-walkthrough(dance.forEach)*/
/*#-code-walkthrough(dance.textView)*/
Text(creature.emoji)
.resizableFont()
.offset(creature.offset)
.rotationEffect(creature.rotation)
/*#-code-walkthrough(dance.textView)*/
//#-learning-code-snippet(exp1)
//#-learning-code-snippet(animationSolution)
//#-learning-code-snippet(exp3)
}
}
/*#-code-walkthrough(dance.onTap)*/
.onTapGesture {
data.randomizeOffsets()
}
/*#-code-walkthrough(dance.onTap)*/
/*#-code-walkthrough(dance.onTap)*/
.onTapGesture {
data.randomizeOffsets()
}
/*#-code-walkthrough(dance.onTap)*/
}
}
}
}
struct DancingCreatures_Previews: PreviewProvider {
static var previews: some View {
DancingCreatures().environmentObject(CreatureZoo())
}
}
Device information: IPad Pro (11 inch, 2nd gen)
iPad OS Version: 26.0.1
Playground Version: 4.6.4
Anyone else come across this?
Thank you in advance.
Swift Playground
RSS for tagLearn and explore coding in Swift through interactive learning experiences on the Swift Playground app for iPadOS and macOS.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm facing an issue with Swift Playgrounds and files created in Xcode 16. It seems that Swift Playgrounds does not support Swift 6, but even when I create files specifically with Swift 5, Swift Playgrounds still reports that the files are unsupported.
This creates a significant problem because macOS Sequoia does not allow me to revert to Xcode 15, which might have offered better compatibility. As it stands, I can't find a solution to work seamlessly between Xcode and Swift Playgrounds.
Has anyone else encountered this issue? Are there any workarounds or updates planned to address this compatibility gap? Any advice would be greatly appreciated!
I am trying to complete the "Initializing Your Expert" lesson in the Swift Playground. Below I post just a snippet of the code that I wrote, since no matter how many lines of code I write, the turnLock() method has no effect whatsoever.
let expert = Expert()
/*Create a function that will move the Expert character forward
the specified number of tiles. This will make the program easier to code and less verbose.
*/
func moveExpert(tiles: Int) {
for tile in 1...tiles {
expert.moveForward()
}
}
/*Create a function to make the Expert do an about face, i.e.
orient itself in the opposite direction.
*/
func aboutFace() {
expert.turnRight()
expert.turnRight()
}
expert.turnLockUp()
The instructions give no information about this method, such as when or where it can and cannot be called. It states merely that calling it is supposed to "reveal the path between the platforms." I don't see multiple platforms in the 3D puzzle world, just one platform with different levels.
No "path between platforms" is ever shown when I call this method, regardless of the location of the Expert character. Why doesn't this method ever do anything at all?
Can anyone advise?
Thank you kindly.
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
While I am not new to programming, I am quite new to the Swift language. I am using the Swift Playground app on macOS 26 on an M1 MacBook Air.
I am on the lesson about types. Perhaps it's a silly question, but what is a portal? It is never described or pointed out where to find it in the puzzle world. Similarly, the instructions reference a "switch" object without ever defining what it is. I cannot write code to call methods or set properties on objects about which I have no useful information. Can anyone advise, please?
Thank you kindly.
I clicked the “Get” button in the Swift tutorial, and it started displaying a circular progress bar. However, when the progress bar was full, it did not show that I could use this tutorial, but still display “Get”.
Device: iPad (7th)
System: iPadOS 18.3.2
App Version: 4.6.4
Hello everyone,
I’m completely new to programming and Apple development, but I’ve always had the strong wish to learn coding and to work more deeply with Apple’s system structures. My main questions are:
How should I best start learning? For example, is Swift Playgrounds the right first step?
How should I continue afterwards to gain further knowledge, possibly in areas like system architecture, cybersecurity, or cloud computing (even though I don’t want to commit too early to one direction)?
Can you recommend a learning schedule or intensity (e.g., how often per day or week I should practice) for someone who works full-time?
Is my current MacBook Air (2020, Intel i3, 8 GB RAM, 250 GB SSD) still suitable for learning and beginner development, or would you recommend upgrading to a newer model?
On top of that, my English is not perfect yet – is it possible to improve it alongside learning coding?
I’m very motivated to finally start this journey, even though I once turned down an IBM apprenticeship when I was younger. Now I want to give it a real try.
Any advice, personal experiences, or learning resources would be very much appreciated.
Thank you in advance!
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
While demonstrating Swift Playground to my students, I noticed that, unlike Xcode, it doesn’t seem possible to predefine or insert custom code snippets. In Xcode, we can easily create and reuse our own code snippets to improve teaching and development efficiency, but I couldn’t find a similar feature in Swift Playground.
Is there currently a way to predefine or insert custom code snippets in Swift Playground? Are there any recommended workarounds, or plans to support this feature in the future? Any suggestions or insights would be greatly appreciated.
Hello
I'm getting this error in my code and I don't know why. Can somebody explain this or point me at a help article.
import UIKit
var greeting = "Hello, playground"
let imageView = UIImageView()
imageView.image = UIImage(named: "image")
Utils.getImageSize(view: imageView)
class Utils {
static func getImageSize(view imageView: UIImageView) {
let image = imageView.image
print("Image size = \(image?.size ?? CGSize.zero)")
}
}
The error is as follows:
Cheers
Murray
Experimenting with #Playground macro with Xcode 26 beta 3, out of the box I see a conflict between duplicates in the XcodeDefault Toolchain. Essentially a clean install of macOS Tahoe 26 25A5306g
FB18930059
Was trying to follow the first Foundation Model WWDC video example but distilling it down to the most basic use of the Playground macro produces the same error.
import Playgrounds
#Playground {
}
Any solutions / workarounds? Wasn't sure whether to attempt to delete one of these–but they are internal libraries.
objc[3241]: Class PGLConcurrentMapNode is implemented in both /Applications/Xcode-beta 3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks/PlaygroundLogger.framework/Versions/A/PlaygroundLogger (0x10db98c10) and /Applications/Xcode-beta 3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libLiveExecutionResultsLogger.dylib (0x10db18050). This may cause spurious casting failures and mysterious crashes. One of the duplicates must be removed or renamed.
error: Couldn't look up symbols:
protocol descriptor for Playgrounds.__PlaygroundsContentRecordContainer```
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
I had several library projects that were working in Swift Playgrounds < 4.6 but I get several duplicate compilation errors and previews will not build in Swift Playgrounds > 4.6. Does anyone know how to fix this issue?
Example project:
This project builds and runs fine under Swift Playgrounds 4.5.1 however it will not run complaining multiple commands produce generated output files under Swift Playgrounds 4.6.1, 4.6.2, and 4.6.3.
https://github.com/kudit/Compatibility
Download this repository and add the extension ".swiftpm" to the folder and double click to open in Swift Playgrounds. If running on earlier Swift Playgrounds you can see there are no errors and previews work great (on both macOS and iPadOS versions of Swift Playgrounds 4.5.x). However, on Swift Playgrounds 4.6.x, previews will not display.
Are embedded libraries not support anymore? This would be very disappointing.
I posted this as a Feedback weeks ago with no response: FB16509699
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
Tags:
Swift Packages
Swift Playground
Playground Support
Certain documentation seems to suggest I can submit a swift playground to the App Store. I am a paid $99 a year developer. In the submission process they ask for my team ID. I am not part of a team. I am an individual. However, my individual account has a team ID associated with it, but they don’t allow me to enter that number in the space provided. There is an * note saying some teams are not permitted to upload to the Apple store connect.
How do I, a paid up developer, submit a swift playgrounds app to the App Store?.
Hi, friends!
I have a Keynote file, in which I create design for macOS applications settings and system settings, that I use and which are installed on my Mac.
I like to record my settings so that every time I reinstall the system or an application I can open my file and set it up exactly the way I want. It's like a user manual, only it looks nice with Mac design elements. And I do it in a presentation (Keynote). I also use a Sketch for the design.
I want to turn all this into an app for myself, using Swift Playground.
Does anyone know how to, for example, add a macOS Dock icon from a Sketch to Swift Playground?
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
Hello the community, how are you?
Since few days, this messages displays as an error into my code: "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions"
Since all these days, I'm not able to solve this problem. My app is almost done and the code is good. But I don't find where the problem is from.
Here's the block where the message appears:
var body: some View { //The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
VStack {
TextField("Search invoices...", text: $searchText)
.padding(10)
.background(Color.gray.opacity(0.1))
.cornerRadius(10)
.padding(.horizontal)
HStack {
ForEach(BillFilter.allCases) { filter in
Button(action: {
selectedFilter = filter
}) {
Text(filter.rawValue)
.padding()
.background(selectedFilter == filter ? Color.accentColor : Color.gray.opacity(0.2))
.foregroundColor(selectedFilter == filter ? .white : .black)
.cornerRadius(8)
}
}
All the best,
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
How can I enable "Extended Runtime Sessions" for a companion watch app? Here https://developer.apple.com/documentation/watchkit/using-extended-runtime-sessions
in targets under 'Signing & Capabilities' I checked "Audio" and Session Type 'Mindfulness',
I created an ExtendedRuntimeManager.swift file. When running a simulation the error message says
"Extended Runtime Session ungültig: Reason=-1, Error=This application does not have appropriate permissions to schedule a session."
How does the app get the 'appropriate permissions'?
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
Tags:
WatchKit
watchOS
Background Tasks
Hi there, I'm currently learning how to write some code using Swift Playgrounds on my Mac, and I'm wondering if there's a way to install the code I create onto my iPhone, like a regular app.
I've searched online quite a bit but haven't found any clear or definitive answers.
Many resources mention a "Run on iPhone" option in Swift Playgrounds, but I don't see that button in my version. I even installed Xcode and connected my iPhone to my Mac, following the instructions I found, but the "Run on iPhone" option still doesn't appear in Playgrounds.
I've updated my Mac, iPhone, and Playgrounds to the latest version. Thank you for your help!
Topic:
Developer Tools & Services
SubTopic:
Swift Playground
Dare anyone try the following code in any Playground:
// Define a model that conforms to Codable
struct User: Codable {
var name: String
var age: Int
var email: String?
}
// JSON data (as a string for demonstration)
let jsonString = """
{
"name": "John Doe",
"age": 30,
"email": "john@example.com"
}
"""
// Convert the JSON string to Data
if let jsonData = jsonString.data(using: .utf8) {
do {
// Parse the JSON data into the User model
let user = try JSONDecoder().decode(User.self, from: jsonData)
print("Name: \(user.name), Age: \(user.age), Email: \(user.email ?? "N/A")")
} catch {
print("Error decoding JSON: \(error)")
}
}
I tested with Xcode 16.2 and latest 16.3, it reliably crashes the lldb server!
第一次接触swift编程,swift playground里面编程入门挺简单的,因为英语也不好,不知道怎么入手了
Hello fellow Techies!
I am currently doing the Swift Playgrounds “Keep Going with Apps” on my iPad Pro. Everything has been going as designed until I got to the ‘Add and Delete Creatures‘ module. The lesson concludes with being able to add a creature to your list in the CreatureZoo. When you run the app from the playground, you can fill out the fields and tap ‘Add’ and that is when the app dims and after 5 seconds I get the notification that the app has an unknown crash. I have reviewed the lessons leading up to it, but I can’t find anything wrong. (Full Disclosure: I really have no clue what I am looking at some of time.)
Has anyone else ran into this?
`import SwiftUI
import Guide
struct CreatureEditor: View {
//#-learning-code-snippet(defineVariablesCreatureEditor)
//#-learning-code-snippet(environmentValue)
@State var newCreature : Creature = Creature(name: "", emoji: "")
@EnvironmentObject var data : CreatureZoo
@Environment(.dismiss) var dismiss
var body: some View {
SPCAssessableGroup(view: self) {
VStack(alignment: .leading) {
Form {
Section("Name") {
//#-learning-code-snippet(addACreatureEditorTextField)
TextField("What is your monster's name?", text: $newCreature.name)
}
Section("Emoji") {
TextField("What does your monster look like?", text: $newCreature.emoji)
}
Section("Creature Preview") {
CreatureRow(creature: newCreature)
}
}
}
.toolbar {
ToolbarItem {
Button("Add") {
data.creatures.append(newCreature)
dismiss()
}
}
}
//#-learning-code-snippet(addButtonToToolbar)
}
}
}
struct CreatureEditor_Previews: PreviewProvider {
static var previews: some View {
NavigationStack() {
CreatureEditor().environmentObject(CreatureZoo())
}
}
}’
] TODO Item
Item 1
Item 2
linkText
TODO Item language
After updating playgroud to the latest 4.6.3 version, the original sample app download interface disappeared. I tried many methods but couldn't find it again. How should I retrieve it again? Or was it deleted in this version?
Topic:
Developer Tools & Services
SubTopic:
Swift Playground