Sound Pad throws an error on the audio device on iPad.
Sound Pad
Version 1.0.0
3 April 2023
Swift 5.8 Edition
A fatal error was found in AudioPlayer.swift
Line which causes this
var engine: AVAudioEngine
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
94 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hello my friends, I am using a Macbook Air M2 chip. After the MacOS Sonoma update, Xcode started to work very slowly. I installed Xcode beta. It still takes 30 minutes to build even the same line of code. Does anyone have an idea for a solution? π₯²
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!
I'm using the latest Playground app (version 4.3.1) and Xcode 15. I'd like to practice code that supports iOS 12 and above. Is there a way to set the deployment target in either the standalone Playground app or within Xcode playgrounds?
This is my first app and I'm very new to coding. I started out with enthusiasm until becoming overwhelmed with Swift coding language...
The app I'm trying to design is very simple and will go hand in hand with the work I do. I attached a screenshot of the UI of what I'm trying to achieve.
All I need the app to do is to let me input the appropriate information, and save it to the table.
The problem is that:
Swift doesn't import source files like C#, whenever I create a new swift file and try to import the file called User.swift, "no file exists named User"
I've looked all over and the examples I'm seeing don't make sense, I dont understand why Xcode/Playground doesn't see it.
Instead of using the UI, I'm writing out:
TextField(Name, text: ???)
I've tried defining a variable in my User.swift file (I can't import which might be the problem).
Even if I could import the User.swift file, I'm not even sure of what would go after the "text:____" spot - I've tried using the $name or changing it to "self.name" and there's always a problem
I realize this may be trivial to some of you but I appreciate your input.
What I'm writing in my User.swift file:
import SwiftUI
struct User {
var name: String
var phone: String
var company: String
var userid: String
var clientid: String
var errorid: String
var notes: String
init(name: String, phone: String, company: String, userid: String, clientid: String, errorid: String, notes: String) {
self.name = name
self.phone = phone
self.company = company
self.userid = userid
self.clientid = clientid
self.errorid = errorid
self.notes = notes
}
}
I have the latest version on macOs and Xcode, since the last update playgrounds doesn't work, the code compiles and runs but the run console doesn't show up and it stucks with the loading icon.
before the last update it worked fine
At the moment with my app Users have to go to Privacy & Security -> Locations Services -> On -> Scroll down to my app and turn on their Location Preference.
I am trying to incorporate in to my app the Code below to make it unecessary to leave the app to enable the Userβs location to be displayed but it does not work.
Please tell me, what am I missing here?
import MapKit
import SwiftUI
import CoreLocation
// Prompt User to choose Location Preference //
class ViewController: UIViewController, CLLocationManagerDelegate{
var locationManager: CLLocationManager?
override func viewDidLoad() {
super.viewDidLoad()
locationManager = CLLocationManager()
locationManager?.delegate = self
locationManager?.requestWhenInUseAuthorization()
view.backgroundColor = .gray
}
}
// The rest of the Code which is working okay ( Map etc.) //
struct Positions: Identifiable {
let id = UUID()
let name: String
let latitude: Double
let longitude: Double
var coordinate: CLLocationCoordinate2D {
CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
}
}
etc.
etc.
Is there a way of deleting an app from the Location Services in the Privacy Setting?
Despite deleting the particular app evidence of it remains.
Also with a particular app there are several of the same in the list. I do understand there may be one for the Playgrounds version and one for the actual downloaded version but I have more.
Is there a way of starting with a clean slate?
When I open a new blank playground in Xcode the very first line "import cocoa" gets the alert "Could not build Objective-C module 'Cocoa'". Can someone please tell me what I have done wrong and how I can fix it.
Xcode 15.0.1
Ventura 13.6.1
Hi,
I want to learn SWIFT and started to use SWIFT Playgrounds 4.4 on iPad and MacBook Air. Unfortunately SWIFT Playgrounds unexpectedly crashes every 2nd to 3rd chapter I work on. I am currently trying to finish "Los gehts mit Code" and "Programmieren lernen 1".
Is the app really so buggy, that it randomly crashes on executing the starting chapters ?
All our custom Playground Books using SpriteKit stopped working after upgrading to SwiftPlaygrounds version 4.4
To reproduce the issue, simply create a new book by clicking the top right hand icon and in the book add two lines of code.
import SpriteKit
let circle = SKShapeNode(circleOfRadius: 100.0)
The second line produces an error. I tried with other classes. SKAction seems to work. SKSpriteNode, SKTexture etc have the same issue. Please help. Our students are stuck!
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)
}
}
}
Hi there,
I am trying to add functionalities for my app developed using Swift Playgrounds environment on mac.
There is a plus button that opens an interface where I can choose the feature in question.
Until here, no problem you would say!
But my problem is that I donβt know which package should I use or even import to develop my application?
Best regards,
Is there a specific name I need to rename the MyPlayground file in order to submit it to the WWDC Swift Student Challenge?
I wanted to take some code I had written in an Xcode project and put it in a playground, though while working on a playground in Xcode, it's showing errors that some lines of code are only supported in iOS 17. I'm updated to the most recent version. Is there any reason why my playgrounds are showing this error?
I assume it might be due to the playground wanting to make sure the app works on older OSs, but a lot of the code I used has no previous counterpart. If this is the case, is there any way I can get around this?
Thanks for taking the time to check this out.
I'm trying to create a simple Regex Builder to parse a timestamp in hh:mm:ss or mm:ss format, a " - " separator, and then a string. I'm trying to use the new Swift RegexBuilder however it doesn't seem to work. It compiles but crashes when running when trying to get the text portion.
Example code in a single playground preview file for reference:
import SwiftUI
import RegexBuilder
struct RegexTestView: View {
var string: String {
let timecode = Regex {
Optionally {
OneOrMore(.whitespace)
}
// timecode section
Optionally {
Capture {
OneOrMore(.digit)
} transform: { match in
Int(match)
}
":"
}
TryCapture {
OneOrMore(.digit)
} transform: { match in
Int(match)
}
":"
// seconds
TryCapture {
OneOrMore(.digit)
Optionally { // miliseconds
"."
OneOrMore(.digit)
}
} transform: { match in
TimeInterval(match)
}
// separator
" - "
Capture { // WHY CAN'T I GET THE REMAINING TEXT???? Any attempts I make to get this result in a crash.
OneOrMore(.any)
} transform: { match in
String(match)
}
}
let tests = [" 222:45:23.2 - foo","2:34:22 - bar"," 2:08 - baz","2:32.18","2:45:23.2 - what"]
var results = ""
for test in tests {
guard let match = test.wholeMatch(of: timecode) else {
results += "MATCH NOT FOUND"
continue
}
results += """
β’β’β’β’
\(match.0)
\(String(describing: match.1))
\(String(describing: match.2))
\(String(describing: match.3))
"""
/*
// Adding this line to the above crashes
\(String(describing: match.4))\n
*/
}
return results
}
var body: some View {
Text(string)
}
}
#Preview("Regex") {
RegexTestView()
}
Hi.
I want to make my Playground Book public.
How can I prepare and provide Swift Playgrounds subscription server?
Thanks.
Using Xcode 15.0.1
The playground, for the code below, has been in "Launching ok" for over two minutes. Anything that I should look into? A little mind boggling actually.
import UIKit
var msg = "Hello World"
print ("\(msg)")
Hi,
I wanted to learn basics on developing in iOS and started with Swift Explorations. I have installed Xcode 15.0.1 and running it on Ventura 13.5.1. When I execute the Playgroung Basics.playground file, I get an error message saying "Failed to attach to stub for playground execution".
Any clue as to why that might be? I am able to create my own playground and execute it properly. I searched around but could not find anything on the topic (other than disablig Rosetta which is not an option as far I can tell in my case; don't see that checkbox under Get Info).
Any pointer would be welcome.
Cheers,
Piloo
I am trying to generate a simple playground to display Table structure with several TableColumns. Basically, generated a new blank playground; add import statements for SwiftUI and PlayGround support; add structure for content view and a statement for invoking that view as:
`PlaygroundPage.current.setLiveView(ContentView())
In general, all of the view components work as expected EXCEPT for the table structure which does not display anything. Its basic structure is:
Table(rows, selection: $selRow) {
TableColumn("ID") {Text(String($0.id))}
TableColumn("Name", value: \.nt)
}
where "rows" is an array of the structure TRow:
struct TRow : Identifiable {
var id:Int
var num:Int
var nt:String
}
Is there some special trick to allowing a SwiftUI Table to be displayed in Playground?