I am building an app playground for SSC'25 where I want to use Multipeer Connectivity framework that would allow me to send and receive data to and from stranger devices. I also want to use some other open-source packages for some of the features. I just wanted to know if we are allowed to use or not?
Swift Playgrounds
RSS for tagLearn and explore coding in Swift through interactive learning experiences on the Swift Playgrounds app for iPadOS and macOS.
Posts under Swift Playgrounds tag
90 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I want to compare the colors of two model entities (spheres). How can i do it? The method i'm currently trying to apply is as follows
case let .color(controlColor) = controlMaterial.baseColor, controlColor == .green {
// Flip target sphere colour
if let targetMaterial = targetsphere.model?.materials.first as? SimpleMaterial,
case let .color(targetColor) = targetMaterial.baseColor, targetColor == .blue {
targetsphere.model?.materials = [SimpleMaterial(color: .green, isMetallic: false)] // Change to |1⟩
} else {
targetsphere.model?.materials = [SimpleMaterial(color: .blue, isMetallic: false)] // Change to |0⟩
}
}
This method (baseColor) was deprecated in swift 15.0 changes to 'color' but i cannot compare the value color to each other.👾
I’m working in the app playground and want to add my usdz file but when i drag drop the file to my main folder i cannot add target to it which leads to a resource not found error while I build my app. It was working on a normal xcode project but while transitioning to app playground it is not working. How can I fix this issue?
When I go to the App Settings menu in Swift Playgrounds and attempt to upload to App Store Connect, I run into the below error screen:
I am registered with the Apple Developer Program.
Swift Playgrounds is updated to its latest version.
This is occurring on both macOS and iPadOS.
All the information I put in is valid.
Any reason why this would be happening?
Hi everyone, I am a new developer.
I am writing some code in swift playgrounds and came across some odd errors. I have looked for solutions and have found nothing. If any more experienced developers could point me in the right direction, that would be great.
Hi, I have recently downloaded the app to start learning how to code in swift and so on.
On my first try I have gotten the error stating that ”.swiftpm files cannot be opened”. I have followed some forum posts. I restarted my iPad several times and redown the app several times. I tried to disable the iCloud sync but I think I deleted the iCloud directory entirely that just results in the app closing on any action taken. (such as pressing the “New App” option or choosing the quick actions to make apps).
Is there a way to fix this?
Any help is appreciate, please ask me to provide any extra needed information.
Hi everyone,
I've been struggling for a few weeks to integrate my Core ML Image Classifier model into my .swiftpm project, and I’m hoping someone can help.
Here’s what I’ve done so far:
I converted my .mlmodel file to .mlmodelc manually via the terminal.
In my Package.swift file, I tried both "copy" and "process" options for the resource.
The issues I’m facing:
When using "process", Xcode gives me the error:
"multiple resources named 'coremldata.bin' in target 'AppModule'."
When using "copy", the app runs, but the model doesn’t work, and the terminal shows:
"A valid manifest does not exist at path: .../Manifest.json."
I even tried creating a Manifest.json manually to test, but this led to more errors, such as:
"File format version must be in the form of major.minor.patch."
"Failed to look up root model."
To check if the problem was specific to my model, I tested other Core ML models in the same setup, but none of them worked either.
I feel stuck and unsure of how to resolve these issues. Any guidance or suggestions would be greatly appreciated. Thanks in advance! :)
Some reason the image 'Ren' is not being loaded even though it is in the project how can I resolve this issue in Xcode Playgrounds?
I’m curious about the situation since the Playgrounds haven’t released a new version to support the numerous new frameworks released this year at WWDC24. How are we supposed to build with these new frameworks if they haven’t even been released for Playgrounds for the Swift Student Challenge?
I’m trying to use the Vision framework in a Swift Playground to perform face detection on an image. The following code works perfectly when I run it in a regular Xcode project, but in an App Playground, I get the error:
Thread 12: EXC_BREAKPOINT (code=1, subcode=0x10321c2a8)
Here's the code:
import SwiftUI
import Vision
struct ContentView: View {
var body: some View {
VStack {
Text("Face Detection")
.font(.largeTitle)
.padding()
Image("me")
.resizable()
.aspectRatio(contentMode: .fit)
.onAppear {
detectFace()
}
}
}
func detectFace() {
guard let cgImage = UIImage(named: "me")?.cgImage else { return }
let request = VNDetectFaceRectanglesRequest { request, error in
if let results = request.results as? [VNFaceObservation] {
print("Detected \(results.count) face(s).")
for face in results {
print("Bounding Box: \(face.boundingBox)")
}
} else {
print("No faces detected.")
}
}
let handler = VNImageRequestHandler(cgImage: cgImage, options: [:])
do {
try handler.perform([request]) // This line causes the error.
} catch {
print("Failed to perform Vision request: \(error)")
}
}
}
The error occurs on this line:
try handler.perform([request])
Details:
This code runs fine in a normal Xcode project (.xcodeproj).
I'm using an App Playground instead (.swiftpm).
The image is being included in the .xcassets folder.
Is there any way I can mitigate this issue? Please do not recommend switching to .xcodeproj, as I am making a submission for Apple's Swift Student Challenge, and they require that I use .swiftpm.
I've entered some code on Version 4.5.1 of Playgrounds on my iPad mini running iOS 18.1.1. The file is saved on iCloud and so is available on my Mac running OS 15.2. However, the file will not open in either Playgrounds v 4.5.1 on the Mac (error "Unable to get file wrapper for contents.xcplayground.") or Xcode 16.1 (error "Couldn't load settings from contents.xcplayground"). The file's type is .playgorund. Any thoughts?
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!
This is my code in ContentView:
import SwiftUI
import SceneKit
import PlaygroundSupport
struct ContentView: View {
var body: some View {
VStack {
Text("SceneKit with SwiftUI")
.font(.headline)
.padding()
SceneView(
scene: loadScene(),
options: [.autoenablesDefaultLighting, .allowsCameraControl]
)
.frame(width: 400, height: 400)
.border(Color.gray, width: 1)
}
}
}
func loadScene() -> SCNScene? {
if let fileURL = Bundle.main.url(forResource: "a", withExtension: "dae") {
do {
let scene = try SCNScene(url: fileURL, options: [
SCNSceneSource.LoadingOption.checkConsistency: true
])
print("Scene loaded successfully.")
return scene
} catch {
print("Error loading scene: \(error.localizedDescription)")
}
} else {
print("Error: Unable to locate a.dae in Resources.")
}
return nil
}
a.dae file exists in the Resources section of macOS Playground app. And a.dae can be viewed in Xcode.
Console shows: Error loading scene: The operation couldn’t be completed. (Foundation._GenericObjCError error 0.)
Any input is appreciated.
I am currently developing my submission for the SSC and I noticed that the swift playgrounds app for iOS does not have support for the new swift ui features in iOS 18. Are we allowed to submit apps that use these iOS 18 only features?
Following the official documentation, I'm trying to create a set of three localised Help Books.
The Help Books should be available in Spanish, English and Polish. Presently, I'm trying to complete English version.
App Structure
This is the plugin application consisting of main app and the plugin. The main app structure would looks as follows:
Files
. <XcodeProject Top>
├── Localizable.xcstrings
├── MyAppExtension
│ ├── MyAppExtension.swift
│ └── <other swift files>.swift
├──MyApp
│ ├── Info.plist
│ ├── +Array.swift
│ ├── +ButtonStyle.swift
│ ├── <other app swift files>.swift
├── Resources
└── MyApp.help
└── MyApp.help
└── Contents
├── Info.plist
└── Resources
├── English.lproj
│ ├── ExactMatch.plist
│ ├── InfoPlist.strings
│ ├── MyApp.helpindex
│ ├── MyApp.html
│ └── pgs
└── shrd
MyApp / MyApp.help / Info.plist file
Consists the following values:
Bundle name: MyApp
HPDBookAccessPath: MyApp.html
HPDBookTitle: My App Help
Default localization: en_gb
MyApp / Info.plist file
Contains the following entries:
Help Book directory name: MyApp.help
Help Book Identifier: MyApp Help
Build phase
The Copy Bundle Resources copies MyApp.help in MyApp/Resources.
Questions
Is the provided folder structure valid for creating a localised help books
Is there anything that is missing from across Info.plist files or is in the wrong places?
Why the MyApp -> Help opens the main help menu, not the app help
Hi everyone I am new to this community and I wanted to ask some help from you guys. I have zero knowledge about swift but I want to learn. Where can I start please help me. Thanks in advance.
I am trying to challenge myself by building an iPhone app in Swift Playgrounds. I just got a Mac Mini M4, so I am trying Swift Playgrounds for Mac.
I can submit a build to TestFlight, but it's for Mac and won't let me even test on my iPhone.
How can I build my app for iPhone?
The least "hacky" answer is appreciated, but I'll entertain anything. Examples in order of hackiness might be:
I missed an option in Playgrounds for Mac.
Open my playground in Xcode, change something, open back in Playgrounds for Mac.
Same as above, but maybe I have to add/copy a file (e.g., manifest.plist).
Open my playground in Playgrounds for iPad (I have an iPad 9), do something, copy back to Playgrounds for Mac.
Submit via Playgrounds for iPad.
Submit via Xcode.
BTW, I'm challenging myself not just for its own sake, but because I'm curious how far a student/newbie/etc can take Swift Playgrounds. I was hoping to set a good example for others looking for a lighter-resource, more user-friendly experience than Xcode (which is why I assume Playgrounds for Mac even exists). But right now it feels like Playgrounds for Mac is a … third-class citizen? Maybe the iPad version is second-class? I haven't really tried it.
P.S. Why does this text editor seem so lame? Making a numbered list and adding to it is a nightmare. Should be: start a numbered list, hit return, new number appears below. I'm on Safari. This should be the best dev experience on the planet, not the worst!
Hi, Could anyone share some insights on how to get and track the 3D coordinates of real objects in the environment in playgrounds? I searched for some resources and noticed ARKit, Reality may be helpful but not sure how to do it.
Can someone help me with this please…
I have two apps which I have updated and have just tried uploading them to the Appstore.
This troubles me because I am paid up to date…
What is the best course of action for me to resolve this please?
I encountered a strange behavior that reminded me of when .sheet() modifiers didn't inherit environment objects. Unless I'm missing something very obvious, it seems to me that TableColumn may expose the same issue. At least on macOS, because the very same code does not crash on iOS.
I'm posting this here before reporting a SwiftUI bug.
Below is a gist for a playground:
https://gist.github.com/keeshux/4a963cdebb1b577b87b08660ce9d3364
I also observe inconsistent behavior when building with Xcode 16.1 or 15.4, specifically:
https://github.com/passepartoutvpn/passepartout/issues/872#issuecomment-2477687967
The workaround I resorted to is re-propagating the environment from the parent:
https://github.com/passepartoutvpn/passepartout/pull/873/files#diff-c662c4607f2adfd0d4e2c2a225e0351ba9c21dbdd5fc68f23bc1ce28a20bce4dR45