Swift Playground

RSS for tag

Learn and explore coding in Swift through interactive learning experiences on the Swift Playground app for iPadOS and macOS.

Posts under Swift Playground tag

60 Posts

Post

Replies

Boosts

Views

Activity

Updating Apps on the AppStore no longer working for me.
I have been using Swift Playground to build and submit my apps to the appstore for around three years now. Recently I uploaded two of my apps but now when I submit them for approval an error is issued… “Unable to Add for Review”… (see pic attached). I don’t understand it because Playground does not use Xcode as far as I am aware? Can someone advise me what I can do to resolve this? Is it something I have to wait to be fixed by an Apple update?
5
0
146
40m
Fixing 'init(contentsOf:)' deprecation warning in macOS 15
Nothing ruins the vibe of a clean file like a yellow warning banner, especially for something that was working perfectly fine yesterday. The "problem" isn't that your code is broken; it’s just that Apple is getting stricter about text encodings in the latest OS versions. They want you to explicitly state how the file should be read (e.g., UTF-8) rather than letting the system guess. On line 30, you just need to add the encoding parameter. For 99% of text files, .utf8 is what you want. Change this: let contents = try String(contentsOf: fileURL) To this: let contents = try String(contentsOf: fileURL, encoding: .utf8) Why is this happening? The Deprecation: As of macOS 15 (and iOS 18), the version of String(contentsOf:) that doesn't require an encoding is officially deprecated. The Logic: Without an explicit encoding, the system tries to "guess" if the file is UTF-8, Windows-1252, etc. If it guesses wrong, you get weird symbols or a crash. By forcing you to add , encoding: .utf8, Apple ensures your code is more predictable and stable. Once you add that one extra argument, that warning should vanish instantly!
0
0
5
4h
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
1
0
808
2w
Swift Playgrounds Incompatibility with Xcode 16 Files and Swift Versions
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!
6
2
1.2k
2w
Reoccurring data access prompt issue with Swift Playgrounds 4.6.4 on macOS 26.1
Hello, I am having a recurring issue using Swift Playgrounds version 4.6.4 on macOS 26.1. Upon opening a file and every other time I start typing in the code section I get a prompt, the image below, two or three times. It doesn't matter if I accept or decline all or some of the prompts, as soon as I start typing on another line I get prompted another two or three times for permission. It appears to me that prompt generates every time the preview pane tries to update. Declining the prompt breaks the preview but accepting the prompt only gets you through a single line of code before it appears again. I believe this issue started after I updated to macOS26.1 as I had not encountered it before. I've also opened other files with Swift Playgrounds and encounter the same problem. It could also be unrelated to the update and could be an issue with some permission setting somewhere, however, I have been unable to find what or where it could be. Is anyone else experiencing this? Thank you for your time :)
28
19
2.7k
3w
Can I withdraw my submission and resubmit an updated playground?
Hello everyone, I have already submitted my app playground for the Swift Student Challenge. After submission I noticed a few things I would like to improve and fix. Is it possible to withdraw my current submission and then immediately resubmit an updated version? Any clarification (especially from Apple staff or anyone who has done this before) would be very helpful. Thank you!
1
0
277
Feb ’26
“Keep Going with Apps” Tutorial section will not complete.
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.
7
6
736
Feb ’26
Are Xcode warnings like this safe to submit (won’t disqualify)?
I’m building a Swift Playgrounds app (.swiftpm) in Xcode 26.2 and I consistently see this warning, even on brand-new Swift Playgrounds apps created from the default template: “Skipping duplicate build file in Compile Sources build phase: /Users/.../.swiftpm/Media.xcassets” Everything builds and runs normally and all images/assets appear correctly, so it seems like it’s just an annoying warning. I’ve checked for duplicates and don’t see the asset catalog listed twice, but the warning still appears whenever I add an asset catalog to any playground project in Xcode. Is this warning safe to ignore for submission, and it won’t affect Swift Student Challenge eligibility?
5
0
342
Feb ’26
Xcode Playground and FoundationModels
I am trying to test FoundationModels in a Swift Playground in Xcode 26.2, macOS 26.3, and am running into an issue. The following simple code generates an error: import FoundationModels @Generable struct Specifications { @Guide(description: "Search for color") var color: String } I see the following error message in the console: error: AIPlayground.playground:4:8: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module 'FoundationModelsMacros' not found The Xcode editor does not appear to recognize the @Generable or @Guide macros, despite importing FoundationModels. What step/setting am I missing?
2
0
156
Feb ’26
What Xcode version will be used for SSC evaluation?
Hello! Because the compilers used by different versions of Xcode 26 may be different, and I find that my app may not be able to ensure that all versions of Xcode 26 are successfully compiled. For example, my app can run on Xcode26.3 but will report an error at 26.4 (I have fixed it now). So I want to confirm which version of Xcode the jury uses to run my app, whether it is a known version or the latest version in the future. Thanks!
1
0
161
Feb ’26
Foundation Models support in Swift Playgrounds | SSC26
Hello. I'm building my Swift Student Challenge Project. But I noticed that the FoundationModels Framework isn't supported in Swift Playgrounds. My app uses ARKit, so it definitely should be tested on real device. So, is it possible to somehow implement a foundation models to my Swift Playgrounds app? Or is it possible to ask judges to test the app on real device launching it from xcode. Your answer is really important for because the functionality of my app directly depends on Foundation Models availability. Thank you!
1
0
168
Feb ’26
Foundation Models support in Swift Playgrounds | SSC26
Hello. I'm building my Swift Student Challenge Project. But I noticed that the FoundationModels Framework isn't supported in Swift Playgrounds. My app uses ARKit, so it definitely should be tested on real device. So, is it possible to somehow implement a foundation models to my Swift Playgrounds app? Or is it possible to ask judges to test the app on real device launching it from xcode. Your answer is really important for because the functionality of my app directly depends on Foundation Models availability. Thank you!
1
0
228
Feb ’26
Does an app relying on CoreLocation (GPS) fit the Swift Student Challenge judging criteria?
Hi everyone, I’m currently developing my submission for the Swift Student Challenge. My app idea heavily relies on CLLocationManager to track the user's movement (recording coordinates, altitude, and calculating distances) to provide a localized, real-world experience. I have a few questions regarding how this will be evaluated during the judging process: Testing Environment: Since the rules mention that Xcode app playgrounds are run in the Simulator, but submissions optimized for iPad are run on real devices, will the judges physically test an app that requires real-world walking/movement? Location Permissions: Will the judges accept the iOS location permission prompts to experience the app, or should I build a "Simulation Mode" with mock GPS data to ensure they can evaluate the core logic without leaving their desk? Judging Criteria: Does a location-dependent app fit well within the "Technical Accomplishment" and "Creativity" criteria, or is it too risky if the judges cannot test the physical movement aspect easily?
1
0
159
Feb ’26
Can I Upload a Single Screenshot Showing iPhone, iPad, and Mac Designs Together?
Hi everyone, I have a question about showcasing my Swift Student Challenge submission. My app includes layouts optimized for iPhone, iPad, and Mac, and I’d like to highlight that it works well across all three device sizes. Would it be acceptable to upload one combined screenshot that shows the same screen displayed on iPhone, iPad, and Mac side-by-side, to demonstrate the responsive design? Thanks in advance for any advice!
1
0
295
Feb ’26
Questions about content usage & submission file
Hi everyone, I have two questions that I hope someone from the community (or Apple team) could help clarify: Use of real Apple Executives in a creative scene In a short introductory scene of my app playground, I included the names and emojis representing Apple executives in a respectful and creative way. There are: No official logos No copyrighted assets No branding elements It is purely fictional and made for storytelling purposes. Would this be acceptable under the submission guidelines, or should all characters be entirely unrelated to real individuals? Submission file concern After submitting my application, I realized I may have accidentally uploaded the wrong ZIP file (I mean I'm not sure tbh). Is there any way to review the exact file that was submitted? Would it be possible to withdraw and resubmit again? If so, would that count as multiple submissions (since only one submission is allowed)? I’d really appreciate any clarification from those who may have experienced something similar or from the Apple team. Many thanks!
0
0
158
Feb ’26
Updating Apps on the AppStore no longer working for me.
I have been using Swift Playground to build and submit my apps to the appstore for around three years now. Recently I uploaded two of my apps but now when I submit them for approval an error is issued… “Unable to Add for Review”… (see pic attached). I don’t understand it because Playground does not use Xcode as far as I am aware? Can someone advise me what I can do to resolve this? Is it something I have to wait to be fixed by an Apple update?
Replies
5
Boosts
0
Views
146
Activity
40m
Fixing 'init(contentsOf:)' deprecation warning in macOS 15
Nothing ruins the vibe of a clean file like a yellow warning banner, especially for something that was working perfectly fine yesterday. The "problem" isn't that your code is broken; it’s just that Apple is getting stricter about text encodings in the latest OS versions. They want you to explicitly state how the file should be read (e.g., UTF-8) rather than letting the system guess. On line 30, you just need to add the encoding parameter. For 99% of text files, .utf8 is what you want. Change this: let contents = try String(contentsOf: fileURL) To this: let contents = try String(contentsOf: fileURL, encoding: .utf8) Why is this happening? The Deprecation: As of macOS 15 (and iOS 18), the version of String(contentsOf:) that doesn't require an encoding is officially deprecated. The Logic: Without an explicit encoding, the system tries to "guess" if the file is UTF-8, Windows-1252, etc. If it guesses wrong, you get weird symbols or a crash. By forcing you to add , encoding: .utf8, Apple ensures your code is more predictable and stable. Once you add that one extra argument, that warning should vanish instantly!
Replies
0
Boosts
0
Views
5
Activity
4h
Swift Playgrounds and App Store Connect
Hello everyone, On my iPad when I press upload to App Store Connect, It tells me uploaded successfully to App Store Connect. When I go to App Store Connect and to Build section, My app is not there. Am I looking in the right place?
Replies
1
Boosts
0
Views
922
Activity
4d
Swift Playground issue with "getting started with apps"
There seems to be an error with a code checkpoint in Swift Playground "getting started with apps" It says to put a VStack inside an HStack and shows how to do it. my screen looks the same but it is not getting marked as correct which is preventing me from moving on. Any Ideas?
Replies
4
Boosts
1
Views
364
Activity
1w
How works Experiment (Documentation) in Swift Playground?
Experiment Create a constant with an explicit type of Float and a value of 4. https://docs.swift.org/swift-book/documentation/the-swift-programming-language/guidedtour
Replies
3
Boosts
0
Views
1.3k
Activity
1w
On iPad with Swift Playgrounds: How to open chapter as a playground?
Note On a Mac with Xcode installed, or on an iPad with Swift Playgrounds, you can open this chapter as a playground. Playgrounds allow you to edit the code listings and see the results immediately. (Note in page 3) (I would like to open the chapter or book: Swift Programming Language in Swift Playground on iPad) https://books.apple.com/ve/book/the-swift-programming-language-swift-5-7-beta/id1002622538?l=en-GB Best regards
Replies
1
Boosts
0
Views
808
Activity
2w
Swift Playgrounds Incompatibility with Xcode 16 Files and Swift Versions
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!
Replies
6
Boosts
2
Views
1.2k
Activity
2w
Reoccurring data access prompt issue with Swift Playgrounds 4.6.4 on macOS 26.1
Hello, I am having a recurring issue using Swift Playgrounds version 4.6.4 on macOS 26.1. Upon opening a file and every other time I start typing in the code section I get a prompt, the image below, two or three times. It doesn't matter if I accept or decline all or some of the prompts, as soon as I start typing on another line I get prompted another two or three times for permission. It appears to me that prompt generates every time the preview pane tries to update. Declining the prompt breaks the preview but accepting the prompt only gets you through a single line of code before it appears again. I believe this issue started after I updated to macOS26.1 as I had not encountered it before. I've also opened other files with Swift Playgrounds and encounter the same problem. It could also be unrelated to the update and could be an issue with some permission setting somewhere, however, I have been unable to find what or where it could be. Is anyone else experiencing this? Thank you for your time :)
Replies
28
Boosts
19
Views
2.7k
Activity
3w
Using .mp3 files in Swift Playgrounds project
Hello, I have an issue with importing some .mp3 files into a swift playground project (in Xcode, not in the Playground app). They worked fine in the Xcode project, but for some reason playgrounds isn't able to find them. I imported them the exact same way as I did in the Xcode project.
Replies
4
Boosts
0
Views
1.4k
Activity
Feb ’26
Can I withdraw my submission and resubmit an updated playground?
Hello everyone, I have already submitted my app playground for the Swift Student Challenge. After submission I noticed a few things I would like to improve and fix. Is it possible to withdraw my current submission and then immediately resubmit an updated version? Any clarification (especially from Apple staff or anyone who has done this before) would be very helpful. Thank you!
Replies
1
Boosts
0
Views
277
Activity
Feb ’26
“Keep Going with Apps” Tutorial section will not complete.
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.
Replies
7
Boosts
6
Views
736
Activity
Feb ’26
Are Xcode warnings like this safe to submit (won’t disqualify)?
I’m building a Swift Playgrounds app (.swiftpm) in Xcode 26.2 and I consistently see this warning, even on brand-new Swift Playgrounds apps created from the default template: “Skipping duplicate build file in Compile Sources build phase: /Users/.../.swiftpm/Media.xcassets” Everything builds and runs normally and all images/assets appear correctly, so it seems like it’s just an annoying warning. I’ve checked for duplicates and don’t see the asset catalog listed twice, but the warning still appears whenever I add an asset catalog to any playground project in Xcode. Is this warning safe to ignore for submission, and it won’t affect Swift Student Challenge eligibility?
Replies
5
Boosts
0
Views
342
Activity
Feb ’26
Xcode Playground and FoundationModels
I am trying to test FoundationModels in a Swift Playground in Xcode 26.2, macOS 26.3, and am running into an issue. The following simple code generates an error: import FoundationModels @Generable struct Specifications { @Guide(description: "Search for color") var color: String } I see the following error message in the console: error: AIPlayground.playground:4:8: external macro implementation type 'FoundationModelsMacros.GenerableMacro' could not be found for macro 'Generable(description:)'; plugin for module 'FoundationModelsMacros' not found The Xcode editor does not appear to recognize the @Generable or @Guide macros, despite importing FoundationModels. What step/setting am I missing?
Replies
2
Boosts
0
Views
156
Activity
Feb ’26
What Xcode version will be used for SSC evaluation?
Hello! Because the compilers used by different versions of Xcode 26 may be different, and I find that my app may not be able to ensure that all versions of Xcode 26 are successfully compiled. For example, my app can run on Xcode26.3 but will report an error at 26.4 (I have fixed it now). So I want to confirm which version of Xcode the jury uses to run my app, whether it is a known version or the latest version in the future. Thanks!
Replies
1
Boosts
0
Views
161
Activity
Feb ’26
Foundation Models compatibility with Swift Playground
There is a week left for end of the Swift Student Challange submissions. I've built an app which uses FoundationModels but unfortunately there is no support for it in the Swift Playground. Is there any chance it might be coming up in the following days?
Replies
1
Boosts
0
Views
169
Activity
Feb ’26
Foundation Models support in Swift Playgrounds | SSC26
Hello. I'm building my Swift Student Challenge Project. But I noticed that the FoundationModels Framework isn't supported in Swift Playgrounds. My app uses ARKit, so it definitely should be tested on real device. So, is it possible to somehow implement a foundation models to my Swift Playgrounds app? Or is it possible to ask judges to test the app on real device launching it from xcode. Your answer is really important for because the functionality of my app directly depends on Foundation Models availability. Thank you!
Replies
1
Boosts
0
Views
168
Activity
Feb ’26
Foundation Models support in Swift Playgrounds | SSC26
Hello. I'm building my Swift Student Challenge Project. But I noticed that the FoundationModels Framework isn't supported in Swift Playgrounds. My app uses ARKit, so it definitely should be tested on real device. So, is it possible to somehow implement a foundation models to my Swift Playgrounds app? Or is it possible to ask judges to test the app on real device launching it from xcode. Your answer is really important for because the functionality of my app directly depends on Foundation Models availability. Thank you!
Replies
1
Boosts
0
Views
228
Activity
Feb ’26
Does an app relying on CoreLocation (GPS) fit the Swift Student Challenge judging criteria?
Hi everyone, I’m currently developing my submission for the Swift Student Challenge. My app idea heavily relies on CLLocationManager to track the user's movement (recording coordinates, altitude, and calculating distances) to provide a localized, real-world experience. I have a few questions regarding how this will be evaluated during the judging process: Testing Environment: Since the rules mention that Xcode app playgrounds are run in the Simulator, but submissions optimized for iPad are run on real devices, will the judges physically test an app that requires real-world walking/movement? Location Permissions: Will the judges accept the iOS location permission prompts to experience the app, or should I build a "Simulation Mode" with mock GPS data to ensure they can evaluate the core logic without leaving their desk? Judging Criteria: Does a location-dependent app fit well within the "Technical Accomplishment" and "Creativity" criteria, or is it too risky if the judges cannot test the physical movement aspect easily?
Replies
1
Boosts
0
Views
159
Activity
Feb ’26
Can I Upload a Single Screenshot Showing iPhone, iPad, and Mac Designs Together?
Hi everyone, I have a question about showcasing my Swift Student Challenge submission. My app includes layouts optimized for iPhone, iPad, and Mac, and I’d like to highlight that it works well across all three device sizes. Would it be acceptable to upload one combined screenshot that shows the same screen displayed on iPhone, iPad, and Mac side-by-side, to demonstrate the responsive design? Thanks in advance for any advice!
Replies
1
Boosts
0
Views
295
Activity
Feb ’26
Questions about content usage & submission file
Hi everyone, I have two questions that I hope someone from the community (or Apple team) could help clarify: Use of real Apple Executives in a creative scene In a short introductory scene of my app playground, I included the names and emojis representing Apple executives in a respectful and creative way. There are: No official logos No copyrighted assets No branding elements It is purely fictional and made for storytelling purposes. Would this be acceptable under the submission guidelines, or should all characters be entirely unrelated to real individuals? Submission file concern After submitting my application, I realized I may have accidentally uploaded the wrong ZIP file (I mean I'm not sure tbh). Is there any way to review the exact file that was submitted? Would it be possible to withdraw and resubmit again? If so, would that count as multiple submissions (since only one submission is allowed)? I’d really appreciate any clarification from those who may have experienced something similar or from the Apple team. Many thanks!
Replies
0
Boosts
0
Views
158
Activity
Feb ’26